Page 1 of 1

Problem with login script!

Posted: Sun Oct 20, 2002 1:53 pm
by lnetzel
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

Posted: Sun Oct 20, 2002 2:03 pm
by mydimension
it looks like you haven't started the session in validateuser.php. add the session_start() to the top of that script.

Posted: Sun Oct 20, 2002 2:03 pm
by hob_goblin
put session_start(); at the top of validateuser.php

Posted: Sun Oct 20, 2002 2:04 pm
by mydimension
great minds think a like :D !!!

Thank you... but still more problem

Posted: Sun Oct 20, 2002 2:42 pm
by lnetzel
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

Posted: Sun Oct 20, 2002 6:28 pm
by qads
put

Code: Select all

session_start();
at the top.