session variable
From: Lüpher Cypher (lupher.cypher_at_verizon.net)
Date: 03/26/05
- Next message: Oli Filth: "Re: session variable"
- Previous message: Lee David: ""if" with blocks of text"
- Next in thread: Oli Filth: "Re: session variable"
- Reply: Oli Filth: "Re: session variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 26 Mar 2005 02:34:19 GMT
Hi,
I am having real trouble understanding what's wrong.
I have two sites that reside locally (for testing) and require login.
One works fine, but the other one seems to discard changes to a session
variable. Anyways, I've compared them and the code is much the same, but
something must be wrong.
Here's excerpts from the second one, the one that doesn't work:
class User {
...
function tryLogin($user,$pass) {
global $user;
... // check db
if (!$match) {
return false;
} else {
$user->name = $row["user"];
$_SESSION["user"] = $user;
}
return true;
}
Now, when the form is submitted, I'm checking:
global $user;
...
if ($submitted) {
if ($user->tryLogin()) {
// redirect via meta tag and output ""
} else {
// output error and form
}
}
where $user is a registered session var (checked that end).
the problem is, if I check $_SESSION["user"]->name after I've changed
$user and updated the session var in tryLogin(), it is all fine. After
that, it is up to the meta tag and surrounding output, which should not
have any effect on this. So, right before the page reloads, name is set
correctly. But when the page reloads, it seems that it is the old $user
object in the session var, as $user->name is not set. Reassigning the
session var should've taken care of it, and it does in my first site,
but here apparently something is wrong. The login mechanism ist
basically the same in both sites, except that I made login as a method
in the second one - I tried taking it out and making it the same as in
the first one - doesn't help..
Any ideas why this could happen?
Lüph
- Next message: Oli Filth: "Re: session variable"
- Previous message: Lee David: ""if" with blocks of text"
- Next in thread: Oli Filth: "Re: session variable"
- Reply: Oli Filth: "Re: session variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|