Click to See Complete Forum and Search --> : need your help (f*cking sessions)


gruetztian
11-07-2003, 08:05 AM
at startup the script jumps into condition two (the else case)
starts a session sets a cookie with the session id and calls the same page again. then the page should read the session cookie (that works) and should check it with the session_id (but that didnt work). can anybody help me please!!!

<?

if(isset($HTTP_COOKIE_VARS['sess']) && $HTTP_COOKIE_VARS['sess'] && session_id())//didnt work
{

echo "logged in...";

}
else
{

session_start();
setcookie("sess",session_id());

echo "<script>location.href = \"self.php\";</script>";

}

?>

(sorry i'm a language putridly german with bad english knowledge there for dont wonder about my construction of sentence)

pyro
11-07-2003, 08:54 AM
Not really sure what you were looking to do. This, perhaps?

<?
session_start();
if (isset($_COOKIE['sess']) && isset($_SESSION['sess'])) {
echo "logged in...";
}
else {
session_start();
$_SESSION['sess'] = true;
setcookie("sess", true);
header("Location:".$_SERVER['PHP_SELF']);
}
?>