note 55073 added to function.setcookie
| From: | (kartikborikar@yahoo.com) | Date: | Mon, 25 Jul 2005 03:21:22 +0000 |
| Subject: | note 55073 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92387@lists.php.net to get a copy of this message | ||
The problem with setcookie() function is that you cannot test whether the cookies were set or not on
the same page. You need refresh the page to see if the cookie was saved.
There is another way of setting the cookie and then checking whether it was set or not set. Set
cookie top of a page and call an PHP file through HTML image tags. The PHP file then checks if the
cookie is set and then send error image or transparent image to the main page.
--- Main PHP Page ---
<?
setcookie ("test", "test" , time()+60*60, "/" );
?> <img src="cookiecheck.php">
--- cookiecheck.php code ---
<?
if(!isset($_COOKIE[test]))
{
readfile("error_text.gif");
}else
{
readfile("trans.gif");
}
?>
You can see this working at http://www.login.kkeim.com/
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55073
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55073&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55073&report=yes
Search -- http://master.php.net/manage/user-notes.php