Click to See Complete Forum and Search --> : sessions???


gruetztian
10-20-2003, 03:22 AM
hello hello,

need help at working with sessions.i think this simple construct needs no description. but whats the
if no post data was send part 3 starts (a formular to enter username and password) and send his data to himself.
part 2 starts (there is a check (i dont want to display it here) with username and password) makes the check and
if all is true he should start a session set a cookie with the session id and start himself again to make the check
in part 1 but the if(direction) (in part 1) doesnt know about the session

//part 1
if(isset($HTTP_COOKIE_VARS['sess']) && $HTTP_COOKIE_VARS['sess'] == session_id()) <-- but i dont get the session id
{

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

}
else
//part 2
if(!isset($HTTP_COOKIE_VARS['sess']) && isset($HTTP_POST_VARS['username']) && isset($HTTP_POST_VARS['passwort']))
{

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

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

}
else
//part 3
//if(!isset($HTTP_COOKIE_VARS['sess']) && !isset($HTTP_POST_VARS['username']) && !isset($HTTP_POST_VARS['passwort']))
{

echo "<form name=\"tform\" method=\"post\" action=\"logon.php\" target=\"main\">";

echo "<table>";

echo "<tr><td>Username:</td><td><input type=\"Text\" name=\"username\" value=\"\"></td></tr>";
echo "<tr><td>Password:</td><td><input type=\"Password\" name=\"passwort\" value=\"\"></td></tr>";
echo "<tr><td>&nbsp;</td></tr>";
echo "<tr><td align=\"right\"><input type=\"Submit\" value=\"Login\"></td></tr>";

echo "</table>";

echo "</form>";

}

whats my problem (cookie params?)?

pyro
10-20-2003, 07:04 AM
Make sure you have session_start() before you try to call the session for the first time...