I'm trying really hard to save my sessions in different directory. I have a shared server in OVH. Default session save path is /tmp
, and I want to change it.
In my root directory I have www
folder which is my main website folder. I created 'sessions' folder next to it, chmoded 777. When I'm doing print_r(scandir('/home/expressptp/sessions/'));
i'm getting files just fine, but when I try to session_save_path('/home/expressptp/sessions');
nothing ever appears there.
Full code looks something like this:
session_save_path('/home/expressptp/sessions');
session_start();
echo session_id();
$_SESSION["test"] = "test";
echo session_save_path(); //that prints good path
But the problem is that in folder sessions
there are no sessions :(
I tried everything. I put 'sessions' folder in 'www', chmod 777, setting path with realpath(dirname($_SERVER['DOCUMENT_ROOT'])
, etc.
If you have any ideas I will be grateful.
Are you absolutely sure nothing in your code has begun outputting ("echo" or html tags or text) to the browser before you try this code?
Many times session/header/cookie functions do not work as expected just because of that...
Also, many host providers do restrict these kind of configurations, have you checked if the session_save_path() function is disabled, or if OVH explicitly prohibits this configuration change?