note 103526 deleted from function.header by tularis
| From: | tularis@php.net | Date: | Fri, 04 Apr 2014 11:19:36 +0000 |
| Subject: | note 103526 deleted from function.header by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-199131@lists.php.net to get a copy of this message | ||
Note Submitter: jphansen at uga dot edu
----
When using header(Location:), if you have the same site that you use which has different URIs, for
example:
www.example.com/a/mysite
www.example.net
you must remain consistent in how you reference it, or $_SESSION[] contents will be lost.
An example would be a user enters www.example.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.example.net/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.example.net');
?>