...

View Full Version : session not working!



rafiki
03-10-2007, 11:50 AM
<?php
session_start();
if ($_SESSION['loggedin'] = 'yessir')
{
echo "congratulations you have logged in ";
} else { header("location: http://rafiki.freehostia.com/register.php");
}
?>


is the page where you cant reach unless you log in
heres a bit of the log in page


$sql = "SELECT 1 FROM 'users' WHERE 'username' = '$username' AND 'password' = $password";
$query = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($query)>0){
$_SESSION['loggedin'] = yessir;
$_SESSION['username'] = $username;
header("Location: http://rafiki.freehostia.com/loggedin.php");
} else {
unset($_SESSION['loggedin']);
but if you visit
http://rafiki.freehostia.com/loggedin.php it doesnt actually redirect back to register.php

Nightfire
03-10-2007, 12:48 PM
if ($_SESSION['loggedin'] == 'yessir')

Should also put quotes around this, as it's a string (4th line)


$_SESSION['loggedin'] = 'yessir';

rafiki
03-10-2007, 01:15 PM
changed it but still echos you have logged in when i go straight to loggedin.php
any other ideas

Inigoesdr
03-10-2007, 02:16 PM
It forwards me to register.php.

Nightfire
03-10-2007, 06:55 PM
changed it but still echos you have logged in when i go straight to loggedin.php
any other ideas

Close your browser and retry. You'll have the session set which is why it's showing that page



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum