Symfony 3.1.5 Warning: Sessionhandler::Read(): Session Data File Is Not Created by Your Uid

Symfony 3.1.5 Warning: SessionHandler::read(): Session data file is not created by your uid

Editing config/config.yml and replacing save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" with save_path: /var/lib/php/sessions fixed the error.

If you use an editor/IDE that automatically converts spaces to tabs, be sure to disable that feature before saving your changes. Failure to do so may cause a 'does not contain valid YAML' error to occur.

Symfony 3 SessionHandler warning

Had the Same trouble when using Vagrant (PHP-FPM 7 + Nginx) with a sync folder (/vagrant ~ default)

Solved just put

    session:
save_path: '/tmp'

on config_dev.yml inside framework entry

Just choose some place that Nginx and PHP can read/write without permission issues.

error when saving php sessions in project's directory

I was able to reproduce the same exact error, creating the session file but throwing "Session data file is not created by your uid.", but I am not sure if this is your case.

Anyway, my guess is that you are using an nfs server to keep your code, but you develop and run nginx locally. You made a nfs mount to the server directory to sync your code to the server(we had the same in one of my previous employments).

So you mount the nfs server directory to a local directory. What happens is that php creates your session file with user www-data, but this user has a different uid on the server than your local machine. So file is created, you see the correct owner, but its uid is different.

Check:

link

link

This is just my best guess. If this is it, let me know, maybe I could help with nfs user mapping. Hope it helps.

Persistence of sessions Symfony 3

I hope this will help people if it happens to them. I found the solution but I still dont know why it works like this :

config.yml:

framework:
session:
enabled: true
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
name: myCookie
cookie_lifetime: 0

in the controller :

public function indexAction(Request $request, SessionInterface $session) {
$cookies = $request->cookies;
$session_id = null;

if($cookies->has('myCookie')) {
$session_id = $cookies->get('myCookie');
} else if (!$session->isStarted() {
$session->start();
$session_id = $session->getId();
$session->set('myCokie', new Cookie('myCookie', $session_id);
}

$response = $this->render ......

$response->headers->setCookie(new Cookie('myCookie', $session_id));

return $response;
}


Related Topics



Leave a reply



Submit