I have these Pages:
login.php (works fine, just HTML code)
validateuser.php (works fine I guess):
//VALIDATE USER
$user_name = $_POST['user_name'];
$password = $_POST['password'];
if (($user_name == 'shaolin') && ($password == 'shaolin')) {
$_SESSION['username'] = $user_name;
echo $_SESSION['username'];
}
else {
echo "login Failed";
}
After I log n with 'shaolin', 'shaolin' the script returns 'shaolin' which would be the Session variable so it's definately set... now the troubles start...
Now I should be logged in and when I try to access my index.php which has the first coderow like:
include 'verifyuser.php';
and... Verifyuser.php has this code:
//CHECK IF USER IS LOGGED IN
session_start();
if(empty($_SESSION['username'])) {
$VerifiedUser = "false";
echo 'Session variabel not set';
}
else {
$VerifiedUser = "true";
echo $_SESSION['username'];
}
.. it returns 'Session variable not set'.. so I wonder where my SET SESSION VARIABLE went... why does'nt my loginscript work? What can I do, please help?
thank you/
Lars Netzel
Problem with login script!
Moderator: General Moderators
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
Thank you... but still more problem
The help you guys gave solved my problem.. very grateful.
Now I can't logout:)...
I created this logout.php which only has this code:
<?
session_destroy();
?>
But it gives me this message:
"Warning: Trying to destroy uninitialized session in logout.php on line 2"
What does this mean? Or is this not the proper way to logout
thank you/
Lars Netzel
Now I can't logout:)...
I created this logout.php which only has this code:
<?
session_destroy();
?>
But it gives me this message:
"Warning: Trying to destroy uninitialized session in logout.php on line 2"
What does this mean? Or is this not the proper way to logout
thank you/
Lars Netzel
put
at the top.
Code: Select all
session_start();