PHP Session Save Path

  • Avinash
  • 3
  • Jan 05, 2012
  • Tips & Tricks

This is the very useful function when you want to get or set your session save path. This function takes only one parameter which is option. This function will used to both set and get the session save path.

What is Session Save Path?

Session save path is path to any directory which will be used to save your session values.

Get Session Save Path

To get the current session save path you just need to call this function without passing any parameter just like below code.

echo session_save_path();
  echo session_save_path();

Set Session Save Path

To set the session save path you will just need to call the same function with parameter which is path of directory. Once you call this function your application’s session save path will get changed so it is good to set this path before calling the session_start(). Have a look at the below code block to set the session save path.

session_save_path("/home/projects/projectx/session/"); // Confirming the path echo session_save_path();
  session_save_path("/home/projects/projectx/session/");
 
  // Confirming the path
  echo session_save_path();

Conclusion

This function will be very handy if you want to store the user related session on any folder which is on web server. You can share your thought if you have used this function on any other way.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: