I'm running into a problem when I try and implement cookie based logins (so people can stay logged in after they close their browser blah blah blah). I'm probably just making a newb problem here, but I have chopped down my code to the following, but it keeps giving me an error when i do "setcookie". Any suggestions on how to fix this? I really appreciate it guys, thanks!
<?
//check to see if the cookie is set
$cookiename = $_COOKIE['duser'];
$cookiepassword = $COOKIE['dpass'];
if(isset($cookiename)){
echo "Welcome $cookiename";
exit();
}
//do this after the login is pressed
if (isset($login)){
echo "You put in $formUser for your username <br>";
echo "You put in $formPass for your password <br>";
setcookie ('duser', $formUser,time()+3600, '/','drewlink.com') or exit("could not set cookie");
setcookie ('dpass', $formPass,time()+3600, '/','drewlink.com') or exit("could not set cookie");
echo "Cookies have been set";
}
?><form action="cookie1.php?login=1" method="post">
Username: <input type="text" name="formUser">
<p>Password: <input type="password" name="formPass"></p>
<p><input type="submit" name="submit" value="login"></p>
</form>


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks