Re: Session Confusion

From: Date: Fri, 23 Mar 2001 21:13:24 +0000
Subject: Re: Session Confusion
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45342@lists.php.net to get a copy of this message
Hi, Just to explain a point on my previous post: If at the top of your page that processes the registration info, you include: session_start(); session_register("is_registered"); is_registered="yes"; and then use this test: if($PHPSESSID) { warning, redirect to login } else { record info, redirect to login } Will the condition in the if statement be true? It seems like it should because you started the session. But a session id is a cookie, and a cookie is not available on the page it is set. So, the first time this script is encountered, e.g. when they register for the first time, even though you started the session, the if statement condition will be false, indicating the first time someone is registering. Subsequently, if someone uses the back button and then clicks submit to get to this page again, then the cookie will be set, and the if statement will return true, causing the other branch of the if statement to execute.

« previous php.general (#45342) next »