Session cookie transfter between subdomains

84 views Asked by At

I have tried all techniques and nothing is working for me. I'm trying to transfer session cookies between subdomains for that mastering website and it's not working.

PAGE #1 (test.php on the root of the domain):

<?php

ini_set('session.cookie_domain', '.mastering.tw');
session_set_cookie_params(0, '/', '.mastering.tw');
session_start();

$_SESSION['test']=1;

?>

PAGE #2 (index.php on one of the subdomains):

<?php

ini_set('session.cookie_domain', '.mastering.tw');
session_set_cookie_params(0, '/', '.mastering.tw');
session_start();

if(isset($_SESSION['test'])) {
echo $_SESSION['test'];
}
else
{
echo 'Session failed!';
}

?>

Any solutions ?

and btw... I'm shared hosting so I prefer not to tweak php.ini unless there is no other choice.

0

There are 0 answers