1

Possible Duplicate:
Where are $_SESSION variables stored?

I'm using this to store some data across page requests (state of two fields from a search form):

session_start();
$_SESSION = $_POST;

I was wondering where are sessions stored? And when do they get deleted?

Community
  • 1
  • 1
Emma
  • 13
  • 2

2 Answers2

3

They are stored in session_save_path. When the session is deleted (after session_destroy or session.gc_maxlifetime), the tmp file is erased and then the space on the HD is reclaimed.

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • So if I don't call session_destroy, they will be stored there forever? – Emma Sep 05 '11 at 21:57
  • @Emma nope, sessions are usually stored in a temporary directory that gets frequently cleaned by the server. The details vary from OS to OS. – Pekka Sep 05 '11 at 21:59
  • @Emma See [`session.gc_maxlifetime`](http://uk2.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime) – NullUserException Sep 05 '11 at 21:59
1

They are stored on the php server, and get deleted after a certain timeout when the server hasn't had a request from the associated client. The timeout is configurable in php.ini or directly from your script.

Gus
  • 7,289
  • 2
  • 26
  • 23