note 69541 added to ref.session
| From: | nhap24 at osu1 dot php dot net | Date: | Sat, 09 Sep 2006 12:03:02 +0000 |
| Subject: | note 69541 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116957@lists.php.net to get a copy of this message | ||
I spent about 8 hours debugging a problem with sessions and redirecting, and I finally found the
problem, which after looking back, should have been the first thing I tried.
I use sessions to prevent hotlinking, so if someone hotlinks my file, I will redirect them to a
different page by re-writing the header information. When I redirected, I sent path information in
the GET data about the file they were trying to access. Long story short, when I redirected with a
forward-slash "/" AFTER the .php, the page would create a different session ID than the
rest of my domain was using. This happened despite the fact that the cookie path was set to
"/" (which should have captured any path on my domain).
The issue was even harder to figure out, because the page with the wrong session ID was NOT creating
a second cookie. The only cookie was the one with the proper ID, but the broken page did not use
this cookie (where then, did it get this ID from?).
To fix the problem, I simply removed the forward-slash from the GET data (base64_encoding works
nicely).
I imagine this is an issue with my browser parsing the url, but I tried both Opera and Firefox (IE
doesn't load anymore :/) and both browsers showed the same problem.
I looked into hidden header data, failure to write the cookie, trans_ses_id (even though it was set
to false), HTTP_HOST, everything, but in the end it was just a stupid forward-slash that had done me
in.
----
Server IP: 216.194.113.175
Probable Submitter: 67.41.7.98
----
Manual Page -- http://www.php.net/manual/en/ref.session.php
Edit -- https://master.php.net/note/edit/69541
Del: integrated -- https://master.php.net/note/delete/69541/integrated
Del: useless -- https://master.php.net/note/delete/69541/useless
Del: bad code -- https://master.php.net/note/delete/69541/bad+code
Del: spam -- https://master.php.net/note/delete/69541/spam
Del: non-english -- https://master.php.net/note/delete/69541/non-english
Del: in docs -- https://master.php.net/note/delete/69541/in+docs
Del: other reasons-- https://master.php.net/note/delete/69541
Reject -- https://master.php.net/note/reject/69541
Search -- https://master.php.net/manage/user-notes.php