Jon
Jon

Reputation: 77

PHP SESSION won't maintain after header() called

This has been asked several times in various flavors, but never answered; it's driving me crazy.

Page 1:

session_start();
$_SESSION["testVariable"] = "test";
header("Location: http://www.mysite.com/page2.php");

Page 2:

session_start();
print_r($_SESSION);

Result:

Array () 

Any ideas? If I echo(session_id()) on both pages, the ID is different. Also, if I comment out the header call, and hit page2.php manually, the session variables are displayed correctly.

Upvotes: 0

Views: 145

Answers (1)

Jon
Jon

Reputation: 77

@Greg said:

Are you accessing the first page from http://mysite.com as opposed to http://www.mysite.com?

Upvotes: 1

Related Questions