user2994429
user2994429

Reputation: 105

Why can't I call my named session cookie in my PHP code?

I've been unable to call upon my $_SESSION variables ever since I added a specific session name to my script.

www.ueteribus.com <--- The login script is hosted here.
carnal.ueteribus.com <--- The Cookie is read and displayed here.

session_name('LoginSession');
session_set_cookie_params(0, '/', '.ueteribus.com');
session_start();

I've been unable to get the information to be sent to the subdomain even using that above script.

The below script is used in my login area, it is supposed to display information on the sub domain about login information.

if (isset($_SESSION['Username'])) 
{
    echo $_SESSION['Username'];
}
?>

Upvotes: 1

Views: 91

Answers (1)

edwardmp
edwardmp

Reputation: 6601

Since you answered this script is not running on any subdomain of ueteribus.com it won't work.

You specified a specific domain where this cookie will work on, check the PHP documentation. Since this is not the domain the script is running on, the cookie is not associated with the script in the right way.

http://php.net/manual/en/function.session-set-cookie-params.php

Either adjust the domain to display the right domain or remove the line session_set_cookie_params line completely.

Upvotes: 1

Related Questions