Re: question about note on php.net

From: Date: Sun, 12 Aug 2007 12:35:23 +0000
Subject: Re: question about note on php.net
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-260732@lists.php.net to get a copy of this message
brian wrote:
Michael Cooper wrote:
Hello, I have a question--is the note from equazcion here correct? It is left unchallenged on the page but I can't see how it is correct since I am under the impression that the environment is refreshed each page load and the function or method definitions (including those for session_set_save_handler) would need to be re-established each page, not each session. I am having tremendous difficulty debugging some code I wrote and eliminating my uncertainty regarding this point would be greatly helpful. Any advice would be appreciated. Thanks!
Because i'm already procrastinating ... google "site:php.net equazcion" http://www.php.net/session_set_save_handler wherein:
equazcion 10-Mar-2007 02:44 I know this might be obvious, but session_set_save_handler() should only be called once per session, or else your saved data will keep getting reset. If your script doesn't have a predictable start page that will only be called only once per session, place the session_set_save_handler statement in an include file, and call it via require_once().
I doubt that this is correct. The save handler that is being set is not, in itself, a part of the session, but a function that is to be used to act upon the session. That is, there isn't anything inherent to the session in the function. Thus, it wouldn't be saved as *a part of* the session. It's just a handler. It's not as if the function, itself, were a container for the session vars.
Looking at the source in head for that function[1] it would appear to fail if a session has already been started, in which case equizcion's comment would be wrong. If the OP is concerned about it I suggest they try it and see what happens. -Stut [1] http://lxr.php.net/source/php-src/ext/session/session.c#1473 -- http://stut.net/

« previous php.general (#260732) next »