Search code examples
sessionshared-hosting

How to change session_save_path in php.ini file?


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?


Solution

  • 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.