RE: [PHP] Session Variables and Redirecting

From: Date: Fri, 13 Jul 2001 18:53:05 +0000
Subject: RE: [PHP] Session Variables and Redirecting
Groups: php.general 
Request: Send a blank email to php-general+get-57784@lists.php.net to get a copy of this message
You should be able to do exactly what you want, I do this myself. I am wondering if you are hitting a bug that is present in PHP in versions prior to 4.0.6, where $someflag and$HTTP_SESSION_VARS["someflag"] do not reference the same value. Try changing two lines in your code to read as below, instead of using the $HTTP_SESSION_VARS array: $someflag = "somevalue"; $failedattempts++; Kirk > -----Original Message----- > From: Johnny Nguyen [mailto:johnny@zugara.com] > Sent: Friday, July 13, 2001 12:36 PM > To: php-general@lists.php.net > Subject: [PHP] Session Variables and Redirecting > > > I've done this on other platforms ASP,Cold Fusion, but I need > to know what's > the best way to do it on PHP. > > 1. grab username and password from POST vars. > 2. select count(*) from users where username = '$username' and > password='$password'... something along these lines > 3. if that user exists and password matches, set a flag on > the user and send > them to the right page, otherwise increment failed attempts > and send them > back to login page. > > if (count > 0) > > session_register("someflag"); > $HTTP_SESSION_VARS["someflag"] = somevalue; > header("Location: secretpage.php"); > } > else > > session_register("failedattempts"); > $HTTP_SESSION_VARS["failedattempts"]++; > header("Location: loginpage.php"); > } > > but apparently, i can't start/register a session and then > redirect. Is > there a better way to do this? > > Regards, > Johnny

« previous php.general (#57784) next »