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 Cookies on a Web Server
How To Test Cookies on a Web Server? - PHP Script Tips - Understanding and Managing Cookies
✍: FYIcenter.com
If you want to test cookies with a browser, you need to run a Web server locally, or have access to a Web server remotely. Then you can copy the following PHP cookie test page, setting_receiving_cookies.php, to the Web server:
<?php setcookie("LoginName","FYICenter"); setcookie("PreferredColor","Blue"); print("<pre>\n"); print("2 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"); ?>
If you open this PHP page with a browser as http://localhost/setting_receiving_cookies.php, you will get:
2 cookies were delivered. Did not received any cookie named as LoginName. 0 cookies received.
"0 cookies received" is because there was no previous visit from this browser. But if you click the refresh button of your browser, you will get:
2 cookies were delivered. Received a cookie named as LoginName: FYICenter 2 cookies received. LoginName = FYICenter PreferredColor = Blue
2007-04-25, 4749👍, 0💬
Popular Posts:
How To Assign Debug Privileges to a User? - Oracle DBA FAQ - Introduction to Oracle SQL Developer In...
How Large Can a Single Cookie Be? - PHP Script Tips - Understanding and Managing Cookies How large c...
. How can a servlet refresh automatically if some new data has entered the database? You can use a c...
How do we generate strong names ? or What is use the of SN.EXE ? or How do we apply strong names to ...
How To Wirte a Simple JUnit Test Class? This is a common test in a job interview. You should be able...