Re: [phplib] PHP4 sessions

From: Date: Sat, 04 Nov 2000 11:40:11 +0000
Subject: Re: [phplib] PHP4 sessions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-23706@lists.php.net to get a copy of this message
Ops! my mistake. I've corrected that but my question remains open. Gera "R.B. Scholtus" wrote: > you cannot register a variable like that, use: > > session_register("var"); > $var++; > > ----- Original Message ----- > From: Gera Makarov <gmakarov@alphalink.com.au> > To: phpgen <php-general@lists.php.net>; phplib <phplib@lists.netuse.de> > Sent: Saturday, November 04, 2000 12:00 AM > Subject: [phplib] PHP4 sessions > > > Hi there, > > > > I am trying to write a simple application which would utilize sessions. > > I don't want to rely on cookies so I pass SID to the relevant pages. > > The two problems I am currently struggling with are, first: how do > > I pass SID to the initial page, the one that starts the session (I can > > actually do it but I'm not sure if that's a good way of doing it, see > > the > > example code below), also when I refresh the initial page it creates a > > new > > session, is there a way to prevent it? and second: when I follow the > > links > > on the first page and then press browser's back button, the browser > > (both > > Netscape and IE5) is asking to refresh the page. Is it possible to avoid > > it? > > > > Thanks in advance. > > Regards, > > > > Gera > > > > > > Here's the code that I wrote: > > > > > > > > session_start(); > > session_register("SESSION"); > > $SESSION[sid] = SID; > > > > ... > > > > // > > // The email and password have been submited. > > // > > if ($SESSION[go] == 1) { > > > > if ( !empty($primary_email) && !empty($password) ) { > > > > if (!isset($SESSION[primary_email]) || > > !isset($SESSION[password])) { > > > > // > > // Incorrect e-mail and/or password. > > // > > if (!$sec->check_user($primary_email, $password)) { > > > > print_messg("Incorrect username / password"); > > session_destroy(); > > exit; > > > > // > > // The user has been authenticated. > > // > > } else { > > > > $SESSION[go] = 2; > > $SESSION[primary_email] = $primary_email; > > $SESSION[password] = $password; > > > > start_html("","Members Area"); > > print_members($SESSION[sid]); > > end_html; > > > > } > > > > } > > > > // > > // Empty e-mail and/or password. > > // > > } else if (empty($primary_email) || empty($password)) { > > > > start_html("",""); > > print_messg("Please enter your e-mail and password"); > > end_html(); > > session_destroy(); > > exit; > > } > > > > // > > // The user is already logged in. > > // > > } else if ($SESSION[go] == 2) { > > > > start_html("","Members Area"); > > print_members($SESSION[sid]); > > end_html; > > > > // > > // The user has not logged in yet or > > // authentication has failed. > > // > > } else { > > > > if (empty($SESSION[go])) $SESSION[go] = 1; > > > > start_html("","Members Area"); > > > > // > > // This will print a form which will ask > > // for e-mail and password, when the form is > > // submited it will return $primary_email > > // and $password to this script > > // > > print_login($SESSION[sid]); > > end_html; > > > > } > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: phplib-unsubscribe@lists.netuse.de > > For additional commands, e-mail: phplib-help@lists.netuse.de

« previous php.general (#23706) next »