note 64563 added to function.setcookie

From: Date: Tue, 18 Apr 2006 19:45:16 +0000
Subject: note 64563 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-108430@lists.php.net to get a copy of this message
I am learning php and am trying to make a simple login script. This is what I have so far. Note: I put a thing to display the cookies on every option for testing purposes. I am having a ton of problems and it doesnt seem like it is working at all. Please help <? $file = "loginscripttest"; //This is the name of the file $password_def = "hello"; //This is the password if ($cmd==login) { if($password==$password_def) { setcookie("lioretest", lit); echo("You have successfully logged in!<br /> Click <a href=\"?cmd=admin\">here</a> to go to administration area.<br>"); echo $_COOKIE["TestCookie"]; echo $HTTP_COOKIE_VARS["TestCookie"]; } } elseif ($cmd==admin && $_COOKIE["lioretest"] = "lit") { echo ("This is the admin center. Click <a href=\"?cmd=logout\">here</a> to log out.<br>"); echo $_COOKIE["TestCookie"]; echo $HTTP_COOKIE_VARS["TestCookie"]; } elseif ($cmd==logout) { setcookie ("lioretest", "", time() - 3600); echo("You have successfully logged out! Click <a href=\"$file.php\">here to log back in.<br>"); echo $_COOKIE["TestCookie"]; echo $HTTP_COOKIE_VARS["TestCookie"]; } else { if ($_COOKIE["lioretest"] = "lit") { echo("Welcome, you are now logged in. Click <a href=\"?cmd=admin\">here</a> to access admin area.<br>"); echo $_COOKIE["TestCookie"]; echo $HTTP_COOKIE_VARS["TestCookie"]; } else { echo("Sorry, you either do not have permission to access this page or are not logged in"); } } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 68.195.52.169 ---- X-Spam-Status: No, hits=3.5 required=5.0 tests=CLICK_BELOW,DATE_MISSING, FROM_NO_LOWER,HTML_LINK_CLICK_HERE,HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/note/edit/64563 Del: integrated -- http://master.php.net/note/delete/64563/integrated Del: useless -- http://master.php.net/note/delete/64563/useless Del: bad code -- http://master.php.net/note/delete/64563/bad+code Del: spam -- http://master.php.net/note/delete/64563/spam Del: non-english -- http://master.php.net/note/delete/64563/non-english Del: in docs -- http://master.php.net/note/delete/64563/in+docs Del: other reasons-- http://master.php.net/note/delete/64563 Reject -- http://master.php.net/note/reject/64563 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108430) next »