PHP Cookie Test -- Client Results

A Tool For Testing Your Browser's Cookie Quotient By Chip Chapin

Chip's Home > WebTools > phpCookieTest    

Page Revision History

  • 2002-11-08 Facelift.
  • 2002-08-13 Updated for PHP 4.2.
  • 2001-11-29 Initial Release (1.0)

Contents

What's Here?

A painless evaluation of your browser's ability to set and return HTTP cookies.

“The Great PHP Cookie Test”

These tests and the idea behind them are derived from "The Great PHP Cookie Test" by Sean McLean at http://www.rnetwork.tv/cookietest/. I have basically just taken Sean's code and repackaged it as a client test to help diagnose cookie problems. Sean used it more to gather statistics on browser behavior.

Your Client's Remote Address: 54.166.62.226
Your Browser's User Agent string: CCBot/2.0 (http://commoncrawl.org/faq/)

There are 13 tested cookie setting procedures, as they appear in Sean McLean's original tests as of 11/29/01. For consistency, I've kept all the same tests, however, tests 6 and 8 incorrectly pass a string instead of the expiration time. This is essentially the same as passing an expiration time of zero. But many PHP coders seem to do this, so Sean included them in the list. Update: Tighter parameter checking in PHP 4.2.x now catches these errors, so tests 6 and 8 were removed August 13, 2002.

$date = gmstrftime("%A, %d-%b-%Y %H:%M:%S",(mktime()+6400) );
$HTTP_HOST = "www.chipchapin.com"; // our server's hostname

1:    header("Set-Cookie: testcookie1=present;");
2:    header("Set-Cookie: testcookie2=present; expires=$date");
3:    header("Set-Cookie: testcookie3=present; expires=$date; path=/");
4:    setcookie("testcookie4", "present");
5:    setcookie("testcookie5", "present", (time()+6400));
  Removed -- 6:    setcookie("testcookie6", "present", "(time()+6400)");
7:    setcookie("testcookie7", "present", (time()+6400), "/", "$HTTP_HOST");
  Removed -- 8:    setcookie("testcookie8", "present", "(time()+6400)", "/", "$HTTP_HOST");
9:    print "<meta http-equiv=\"Set-Cookie\" content=\"testcookie9=present\">\n";
10:   print "<meta http-equiv=\"Set-Cookie\" content=\"testcookie10=present; expires=$date\">\n";
11:   print "<meta http-equiv=\"Set-Cookie\" content=\"testcookie11=present; expires=$date; path=/\">\n";
12:   print "<script>document.cookie = 'testcookie12' + '=' + 'present';</script>\n";
13:   header("Set-Cookie: testcookie13=present; path=/; domain=$HTTP_HOST; expires=".gmstrftime("%A, %d-%b-%Y %H:%M:%S GMT",time()+9600));

YOUR Results

Below are the results for your current address and browser:

No results are currently available.  Please rerun the tests.

Ideally, all methods should test 'OK'. To re-run the tests, click here.

Got Failures? Check Your System Date ...

Your client's system date should be close to "correct". Please compare it to our server's system date. If your system date is significantly wrong, then you will have problems with cookie expiration times. In fact, when I developed this test page to help me resolve a client problem, it turned out that the client's date was set 8 years in the future (2009 instead of 2001) so every cookie with an expiration date failed.

Our Server's System Date: Dec 19 2014 07:54:39 GMT/UTC
Your Client's System Date:

Want More Info About Cookies?

For detailed (though conflicting) information about setting cookies in PHP see the annotated online PHP Manual. Here are some other useful cookie resources:

Netscape Spec: HTTP Cookies
Netscape's preliminary specification, "Persistent Client State: HTTP Cookies" provides a simple and readable introduction to the client-server protocol required by cookies.
RFC 2965 -- "HTTP State Management Mechanism"
The October 2000 internet standard for HTTP cookies.
Microsoft's Description of Cookies
An overview document with links to various resources, including relevant Microsoft support issues and external standards.

Source Code Here...

To see the source code for this page (including all the tests) click here.

.

Valid HTML 4.0! Valid CSS! Chip's Home Page

Updated Friday November 08, 2002 16:53:35 PST