note 22194 modified in function.session-set-save-handler by danbrown

From: Date: Sun, 23 Jan 2011 16:22:24 +0000
Subject: note 22194 modified in function.session-set-save-handler by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176058@lists.php.net to get a copy of this message
if you want to call session_start again after session_destroy, you have to call session_set_save_handler a second time. otherwise the session module doesn't know about all the nice functions you defined earlier because it has been destroyed. example: <?php # session handlers functions are defined # somewhere else session_set_save_handler ("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_start(); # do some stuff ... session_destroy(); # call this again, because session_destroy # destroys more than just the session. session_set_save_handler ("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_start(); # ... ?> we need to call session_start() twice in our login script to prevent multiple logins. i tore my hair out over this one. hope this helps someone else. :) --was-- if you want to call session_start again after session_destroy, you have to call session_set_save_handler a second time. otherwise the session module doesn't know about all the nice functions you defined earlier because it has been destroyed. example: # session handlers functions are defined # somewhere else session_set_save_handler ("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_start(); # do some stuff ... session_destroy(); # call this again, because session_destroy # destroys more than just the session. session_set_save_handler ("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc"); session_start(); ... we need to call session_start() twice in our login script to prevent multiple logins. i tore my hair out over this one. hope this helps someone else. :) http://php.net/manual/en/function.session-set-save-handler.php

« previous php.notes (#176058) next »