Save path PHP sessions

Views: 7 Last modified: July 31st, 2011 Comments: 0

You can define a path to save your session files. Those file are generated when initializing a session and are commonly prefixed with “sess_” followed with the session ID. Go to your php.ini and search for:

session.save_path

You will probably find 2 results, you need the without the MODE option. It’s possible that you find an semicolon in front of it, if so, just remove it.

Now you can specify a path to a directory (need’s to be created in advance) where you want the session files saved. In this example the files are saved in a map, called sessions.

session.save_path = “C:\server\sessions”

However, changing your php.ini file is not the only way to do it. You can specify a save path manually for a particular session only. Again, i used the same path as at the example earlier mentioned.

// Needs to be called before session_start()
session_save_path('C:\server\sessions');

// Initialize the session
session_start();

This line needs to be called before session_start() and needs to be repeated on each of the session related pages, otherwise the default save path will be used.

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)
    Bluehost

    Mail this!

    To: From:Sum {4+9} =  
    Anything to add ?

        You must be logged in to post a comment.