How to change session_save_path in php.ini file?

Okan Kocyigit picture Okan Kocyigit · Jan 19, 2012 · Viewed 97.8k times · Source

I have a shared hosting on godaddy.

I tried to change session save path in php.ini file with this line,

sessions.save_path = "/session"

I've controlled the sessions save path with sessions.save_path() function. It returns /tmp before and after changing php.ini

Is it possible to change session save path on shared hosting?
Where am I wrong?

Answer

Mughil picture Mughil · Jan 19, 2012

You can modify the session save path on shared hosting by creating a custom php.ini.

Include this in your file: session.save_path = "/path/to/your/folder"

Otherwise, you can use:

ini_set('session.save_path', '/path/to/your/folder')

The folder you use should be under your domain/account but not accessible through a Web browser. It also needs to have world-writable permissions on it. And every page that uses sessions must include that line.