This is on login.php setcookie('LOGGED_IN','True_',time()+3600*24*3); setcookie('USERNAME',$_POST['username'],time()+3600*24*3); Code (markup): This is on index.php echo '<!--' . $_COOKIE['LOGGED_IN'] . '-->'; echo '<!--' . $_COOKIE['USERNAME'] . '-->'; Code (markup): Along with another script to test the cookies, however it doesn't show anything almost like the cookie isn't being set. I have looked over the script many times but I don't see what is wrong. print_r($_COOKIE) also comes up blank. I don't see anything wrong with the syntax of either thing.
lol maybe because of these? '<!--' Code (markup): And '-->' Code (markup): Those are syntax for comments on HTML.
Yes and when I look at the source code it is blank comments. Also the problem is that the cookie is being set.
Try to put it in double quotes like this: setcookie("LOGGED_IN","True_",time()+3600*24*3); setcookie("USERNAME",$_POST['username'],time()+3600*24*3); PHP: EDIT: I've tested it, I don't think there's any difference in being single or double quotes but it should work no problem either way. =/ The first time, there were no variables present, it was blank as you said. Then I refreshed it and it just magically appeared. I'm not exactly sure why though, gotta research that. You can alternately use PHP sessions if you continue to have issues with it.
That was a good idea but sadly it didn't work. For some reason it isn't working for me. I even stuck it on the same page right before where it is supposed to echo the cookie contents and it doesn't work.
i also have some problem when i try to make a cookie like: setcookie("USERNAME",$_POST['username'],time()+3600*24*3); well i tried this: $name="$_POST[username]"; setcookie("USERNAME",$name,time()+3600*24*3);' PHP: and also i don;t think two cookies can be set at once.
If you read this, under Common Pitfalls, it says: So I guess that's why. =/ I believe it can be set twice. But there's a limit per domain.
Ugh, I don't like sessions but I guess I will have to use them anyway because these cookies just absolutely won't set. This is really odd... now the sessions aren't setting.
$o_username = $_POST['username']; session_start(); $_SESSION["LOGGED_IN"] = "True_"; $_SESSION["USERNAME"] = $o_username; session_destroy(); Code (markup): For some reason this isn't setting.
PHP sessions are way more secure than cookies because it stores cookies on the server, not the user's computer where they full access - they can modify/delete/add cookies. Try this: <?php session_start(); $_SESSION['LOGGED_IN'] = "True_"; $_SESSION['USERNAME'] = "lol"; echo $_SESSION['LOGGED_IN']; echo $_SESSION['USERNAME']; unset($_SESSION['USERNAME']); unset($_SESSION['LOGGED_IN']); ?> PHP: