RE: [PHP] SESSION PROBLEMS
| From: | John W. Holmes | Date: | Sun, 27 Apr 2003 22:38:48 +0000 |
| Subject: | RE: [PHP] SESSION PROBLEMS | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145444@lists.php.net to get a copy of this message | ||
> I am new to php and I have recently started using sessions. I am
getting
> some unusual behavior that I am unable to figure out. Currently, I
have a
> validate page that starts a session. If the user is validated, then
the
> user
> is re-directed to another page called main.php in another directory.
>
> session_start();
[snip]
> header("Location: ../employee_mngr/main.php");
Sessions use cookies. When you set a cookie in a certain directory, it's
not available to directories above it. Therefore, when you start a
session in a subdirectory and then redirect to a directory above it, the
session cookie is not going to be valid, so neither is the session.
However, you could probably use the session functions to set the domain
of the cookie to '/' which will make it valid for the entire site.
Also, you should use a complete URL in your header() function:
Header('Location: http://www.yourdomain.com/file.php');
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/