Jump to content

[SOLVED] php cookie question


Reaper0167

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.