| Chip's Home > WebTools > phpCookieTest | ||
| |
||
| Page Revision History
Contents |
A painless evaluation of your browser's ability to set and return HTTP cookies.
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.224.79.93
Your Browser's User Agent string: CCBot/2.0
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));
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.
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: May 19 2013 00:09:39 GMT/UTC
Your Client's System Date:
For detailed (though conflicting) information about setting cookies in PHP see the annotated online PHP Manual. Here are some other useful cookie resources:
To see the source code for this page (including all the tests) click here.
.| |
||||
|
||||
| |
||||
|
Updated
Friday November 08, 2002 16:53:35 PST |
||||