Reputation: 332
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
Upvotes: 7
Views: 38788
Reputation: 276
In my case, I have xampp with M1 ARM based please follow the below steps if you have the same
First find session.save_path from http://localhost/dashboard/phpinfo.php
Then remove all existing sessions
I followed the above & it worked
Upvotes: 0
Reputation: 66
The solution for me was just to wipe the contents of the sessions folder. Not sure how or why that helped, but it did.
Upvotes: -1
Reputation: 1112
For lampp users,
- go to /opt/lampp/temp/
- delete session file, and test again
After testing again,
If error message "Wrong permissions on configuration file, should not be world writable!" shows,
Run the following at terminal:
sudo chmod 755 /opt/lampp/phpmyadmin/config.inc.php
That worked for me ...
Upvotes: 0
Reputation: 6169
What worked for me, could work for you as well.
It looks like something went wrong with the session. Open the browser's DevTools and delete all Sessioncookies.
Upvotes: 2
Reputation: 389
On Ubuntu within Windows 10 , my php user is the default user I create for the first install, I dont know why because the etc/apache2/envvars
is not configured like that.
Nevermind, I change it for fix it quickly and now, it works.
export APACHE_RUN_USER=rudak
export APACHE_RUN_GROUP=rudak
Upvotes: 3
Reputation: 71
this works for me:
sudo chown -R www-data:www-data /var/lib/php/sessions
Upvotes: 5
Reputation: 790
Editing config/config.yml and replacing save_path:
session:
save_path: '/tmp'
Upvotes: 4
Reputation: 760
Another solution: rename your session folder var/session to var/session_old
create a new folder var/session
and delete the old one.
Upvotes: 0
Reputation: 683
I use this to also make Named Pipes in php.
<?php
$user = get_current_user(); // get current process user
// We need to modify the permissions so users can write to it
exec( "chown -R {$user}:{$user} $fifoPath" );
Upvotes: 1
Reputation: 2272
I could be that your Session file was created by another user (well UID), try (re)moving the session file(s) from your temp dir something like /var/tmp
Upvotes: 1
Reputation: 3064
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.
Upvotes: 13