Date: 11/03/00
- Next message: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Previous message: Sascha Schumann: "Re: [phplib] sessions, php4 vs. phplib"
- Next in thread: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Reply: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Previous message: Sascha Schumann: "Re: [phplib] sessions, php4 vs. phplib"
- Next in thread: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Reply: R.B. Scholtus: "Re: [phplib] PHP4 sessions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

