I want to store the created sessions in a directory above the root, except when I use any of the following:
session_save_path($_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions');
session_save_path($_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions/'); // With an extra slash at the end
ini_set('session.save_path', $_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions');
ini_set('session.save_path', $_SERVER['DOCUMENT_ROOT'] . '/../storage/sessions/'); // Again with the extra slash
and not one of these methods work, whenever I load the page I get the following errors:
Warning: session_start(): Session data file is not created by your uid in /var/www/bootstrap/bootstrap.php on line 25
Warning: session_start(): Failed to read session data: files (path: /var/www/public/../storage/sessions/) in /var/www/bootstrap/bootstrap.php on line 25
Can anyone help me?
Edit: My server runs on PHP 7.1
PHP requires session file to be owned by the user running PHP.
Then just run chown -R www-data:www-data /var/www/storage/sessions/
to own session folder and files by your PHP user (www-data:www-data
are your PHP user and group separated by :
).
You can use PHP method get_current_user()
or run in bash php -i | grep user
and find your user running PHP there.
Editing config/config.yml and replacing save_path:
session:
save_path: '/tmp'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With