Reaper0167 Posted July 13, 2009 Share Posted July 13, 2009 Online i see examples of this everywhere, but I cannot get it to work. I can enter any value in the text box and it will still echo. <?php if (isset($_POST['submit'])) { $ident = $_POST['id_password']; $ident = (int)$ident; if ($ident == "1234") { setcookie("Auth"); } } ?> <?php if(isset($_COOKIE['Auth'])) { echo 'Unique Hits = ' . $count . ''; } ?> Link to comment https://forums.phpfreaks.com/topic/165865-solved-php-cookie-question/ Share on other sites More sharing options...
Reaper0167 Posted July 14, 2009 Author Share Posted July 14, 2009 I woul only like it to echo if the correct 1234 is entered. This is driving me nuts. Everything seems ok, but this is the first time dealing with cookies. Link to comment https://forums.phpfreaks.com/topic/165865-solved-php-cookie-question/#findComment-874908 Share on other sites More sharing options...
rhodesa Posted July 14, 2009 Share Posted July 14, 2009 You may wanna read up more on how that function is used: http://us.php.net/setcookie 1) While setting an empty cookie is fine and all, you should probably delete the cookie if it's an invalid password. 2) $_COOKIE is set at before the script is run. So, anything done with setcookie is not reflected in $_COOKIE until the next time the page is loaded Link to comment https://forums.phpfreaks.com/topic/165865-solved-php-cookie-question/#findComment-874923 Share on other sites More sharing options...
Reaper0167 Posted July 14, 2009 Author Share Posted July 14, 2009 thanks Link to comment https://forums.phpfreaks.com/topic/165865-solved-php-cookie-question/#findComment-874927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.