View Full Version : not accessing some sessions

06-27-2005, 11:46 PM
ok, im about to tear my hair out over this and im sure its some really easy problem to fix, bassically, i have a session ($_SESSION['loggedin']), and i access it with an if statement towards the top of a page, if the statement returns TRUE, then it prints some stuff out, if it returns FALSE, then it prints something else out. but this doesnt work, it always prints out what it should if the IF statement were false.

heres why its confusing: later in the same script, i access the same session, with the exact same if statement, and it works flawlessly. i dont alter, touch, even access the session in between these two instances. as well, the session isnt set on the page its being accessed from, so im lost, code is below:

if ($_SESSION['loggedin'] == TRUE) {
print("Messaging system coming in next release!");
} else {
<form name="login" action="index.php?action=login" method="POST">
Username:<input type="text" name="username"> &nbsp;&nbsp;
Password:<input type="password" name="password">
<input type="submit" value="Submit">

heres where the session works and is accessed perfectly

if ($_SESSION['loggedin'] == TRUE) {
print("<div align=\"center\">Logged in as: <br> " . $_SESSION['username']);
print("<hr width=\"100\"> <br> <a href=\"index.php?action=login&mode=logout\">Logout</a>");

please help, thanks

06-28-2005, 12:25 AM
Do you have session_start() somewhere before the if?

06-28-2005, 12:48 AM
yes, its at the very begining of the page

06-28-2005, 12:48 AM
Usually, in my experience, session problems occur when you forget to use:


at the top of the page, or you forget to define your session variables, or you're session variables are set using faulty POST data....

06-28-2005, 12:49 AM
ok, figured it out, i had session_start; rather than session_start();

i got an error for something else on the same line, changed both of them, and well, kinda hard to describe, anyways thanks for the help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum