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 entryJust 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
PHP Upload File Enhance Security
Mysqli_Store_Result() VS. MySQLi_Use_Result()
The Behaviour of the or Operator in PHP
What Is the Js Equivalent to the PHP Function Number_Format
Difference Between Directoryiterator and Filesystemiterator
Using PHP & Curl to Login to My Websites Form
Make Script Execution to Unlimited
Error Starting Userland Proxy: Listen Tcp 0.0.0.0:3306: Bind: Address Already in Use
Best Way to Get Hostname with PHP
Upload File Using Guzzle 6 to API Endpoint
Session_Start Seems to Be Very Slow (But Only Sometimes)
How to Call Curl_Setopt with Curlopt_Httpheader Multiple Times to Set Multiple Headers
How to Use a PHP Class from Another File
How to Route Get and Post for Same Pattern in Laravel
Speeding Up Large Numbers of MySQL Updates and Inserts
Mongodb: Benefit of Using Objectid VS a String Containing an Id
PHP MySQL - Insert into Without Using Column Names But with Autoincrement Field