Re: Session problem in back button

From: Date: Tue, 26 Aug 2003 04:01:49 +0000
Subject: Re: Session problem in back button
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160719@lists.php.net to get a copy of this message
Seems confusing. ------------------------- //include.php session_name("sessionname"); session_start(); -------------------------->> This was added in a separate file and included that file in all the files including index.php In index.php I registered a variable s_authed and initialised it to 0 ----------------------------- //index.php include "include.php"; session_register("s_authed"); $s_authed = 0; // initialize session flag ----------------------------->> And after sign up I am authenticating the user in a separate file and setting a flag s_authed to 1 ----------------------------- //auth.php if(check for authentication) { ........ $HTTP_SESSION_VARS['s_authed']=1; } ----------------------------->> Now in the main.php I am checking ----------------------------- //main.php if($s_authed==1) { //Display login form code goes here } else { display "authentication required"; } ----------------------------->> This is working fine. Even when I copy and paste the URL to another browser it is showing authentication required page. When I used if (!isset($_SESSION['sessionname'])) { //Display login form code goes here } in main.php it is not working. I mean that it display the page even when I copy and paste URL in a new browser window. Seems like an essay :) Why is it so. Is that my previous method was correct or any mistakes I did? -murugesan ----- Original Message ----- From: "Paul Fitzpatrick" <pfitz@dodo.com.au> To: <php-general@lists.php.net> Sent: Tuesday, August 26, 2003 10:43 PM Subject: RE: [PHP] Session problem in back button > > Hi, > > This will stop them seeing the login once they are in a registered > session > Only diplay the login form if NOT a registered session variable > 'sessionname' (or some other session variable) > > > If (!isset($_SESSION['sessionname'])) > { > //Display login form code goes here > } > > Cheers. > > > > > -----Original Message----- > From: murugesan [mailto:mukeshgct@hotmail.com] > Sent: Monday, August 25, 2003 9:55 AM > To: murugesan; Cody Phanekham; php-general@lists.php.net > Subject: [PHP] Session problem in back button > > Hello all, > Now i have a problem in back button. > After signing in when I click back button It goes to login page. > But > when I click the forward button it is going to the main page. > How can I prevent this. > > -murugesan > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#160719) next »