Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Test Persistent Cookies
How To Test Persistent Cookies? - PHP Script Tips - Understanding and Managing Cookies
✍: FYIcenter.com
If you want to test persistent cookies, you can copy the following PHP script, setting_persistent_cookies.php, to your Web server:
<?php setcookie("LoginName","FYICenter"); setcookie("PreferredColor","Blue"); setcookie("CouponNumber","07470433",time()+60*60*24*7); setcookie("CouponValue","100.00",time()+60*60*24*7); print("<pre>\n"); print("2 temporary cookies were delivered.\n"); print("2 consistent cookies were delivered.\n"); if (isset($_COOKIE["LoginName"])) { $loginName = $_COOKIE["LoginName"]; print("Received a cookie named as LoginName: ".$loginName."\n"); } else { print("Did not received any cookie named as LoginName.\n"); } $count = count($_COOKIE); print("$count cookies received.\n"); foreach ($_COOKIE as $name => $value) { print " $name = $value\n"; } print("</pre>\n"); ?>
Open your browser to visit this page: http://localhost/setting_persistent_cookies.php. You will see:
2 temporary cookies were delivered. 2 consistent cookies were delivered. Did not received any cookie named as LoginName. 0 cookies received.
Click the refresh button, you will see:
2 temporary cookies were delivered. 2 consistent cookies were delivered. Received a cookie named as LoginName: FYICenter 4 cookies received. LoginName = FYICenter PreferredColor = Blue CouponNumber = 07470433 CouponValue = 100.00
Close your browser and open it again to the same page. You will see:
2 temporary cookies were delivered. 2 consistent cookies were delivered. Did not received any cookie named as LoginName. 2 cookies received. CouponNumber = 07470433 CouponValue = 100.00
This proves that "CouponNumber" and CouponValue" persisted outside the browser.
2007-04-25, 4924👍, 0💬
Popular Posts:
How did you implement UML in your project ? PART II Implementation phase / Coding phase (Class diagr...
How To Export Data to a CSV File? - Oracle DBA FAQ - Introduction to Oracle SQL Developer If you wan...
The object that contains all the properties and methods for every ASP.NET page, that is built is .. ...
How Large Can a Single Cookie Be? - PHP Script Tips - Understanding and Managing Cookies How large c...
Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written...