note 90991 deleted from function.session-register by cmb

From: Date: Wed, 24 Feb 2021 12:10:44 +0000
Subject: note 90991 deleted from function.session-register by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-219260@lists.php.net to get a copy of this message
Note Submitter: kavih7 at yahoo dot com ---- For those of you who use this function (session_register that is), even though the manual does specify that this function implicitly calls session_start(), I just wanted to reiterate that fact. It is also important to know that if you ever switch from session_register to using $_SESSION, make sure to call session_start before adding items to the $_SESSION variable, because unlike session_register, no implicit call to session_start is done. Another reason I explain this is because I ran into a problem in which you can add items to the $_SESSION variable all you want, but if session_start is not called before adding them, they will not actually be saved to the session. Using the same code, though, and replacing the $_SESSION assignments with session_register without calling session_start WILL save that info to the session. It would be nice to have PHP check for writes to the $_SESSION variable and complain with a warning if session_start hasn't been called.

« previous php.notes (#219260) next »