note 103526 added to function.header
| From: | jphansen at uga dot edu | Date: | Mon, 18 Apr 2011 15:47:02 +0000 |
| Subject: | note 103526 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178946@lists.php.net to get a copy of this message | ||
When using header(Location:), if you have the same site that you use which has different URIs, for
example:
www.mainserver.com/a/mysite
www.mysite.com
you must remain consistent in how you reference it, or $_SESSION[] contents will be lost.
An example would be a user enters www.mainserver.com/a/mysite, then based on some decision they
make, you want to header(Location:) them to another page. If you header(Location: http://www.mysite.com/page.php), $_SESSION[] will be lost.
I solved this by forwarding them to a particular URI before I start saving $_SESSION[] variables:
<?php
if (strpos($_SERVER['REQUEST_URI'], "/a/mysite/") !== false)
header('Location: http://www.mysite.com');
?>
----
Server IP: 69.147.83.197
Probable Submitter: 128.192.32.117
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/103526
Del: integrated -- https://master.php.net/note/delete/103526/integrated
Del: useless -- https://master.php.net/note/delete/103526/useless
Del: bad code -- https://master.php.net/note/delete/103526/bad+code
Del: spam -- https://master.php.net/note/delete/103526/spam
Del: non-english -- https://master.php.net/note/delete/103526/non-english
Del: in docs -- https://master.php.net/note/delete/103526/in+docs
Del: other reasons-- https://master.php.net/note/delete/103526
Reject -- https://master.php.net/note/reject/103526
Search -- https://master.php.net/manage/user-notes.php