You must first start a session in order to use the session_ * functions. So, first of all you need to do the following:
session_start();
then you can request a session id like this
$id = session_id();
Please note that it is not recommended to save the sessions in a public folder accessible to the public, as visitors can find the folder in which you save the sessions and list all of them. They can then insert session cookies into their browser and manage other user user accounts. If you really need to do this, restrict access to the / tmp folder. For example, put the .htaccess file in this folder using this code
Deny from all
Or find another way to disable users from viewing your / tmp folder, as this may be a security issue.
If you want to change the session identifier for each request, for security reasons, you can use the session_regenerate_id function
You would do something like this:
session_start(); session_regenerate_id();
This way, even if someone steals your session cookie, the session ID will be changed with every request. And that could be your problem. There is a PHP way to restore a new session id for each request, so this may bother you.
Regarding the installation of php.ini directives, you should check if your hosting provider has allowed you to change the .ini directive that you are trying to change. It depends on the server setting if you can change the .ini directive or not. And the behavior of the sessions may differ from hosting to hosting, depending on how they configure the server. Most things can be changed using php functions or using ini_set with this list of php.ini directives
source share