Cross domain session

I have some pages like the following.

We can see the pages above is at the following.


Each page has the php code below.


<?php session_start(); $_SESSION[-'mySession_name'-]='mySession_Value'; ?>


<?php session_start(); echo $_SESSION['mySession_name'].'
'; ?>


<?php session_start(); unset($_SESSION['mySession_name']); ?>

[/code] I like to make like the following.
if a user opens the echo_session page at after opening the set_session page at, the result outputs “mySession_Value”.

Can I do that with your help?
(Please notice, “” is a subDomain of “”.)

First line of code: (Yes, even before session_start)

session_set_cookie_params(0, '/', '');

(feel free to replace 0 with whatever timeout you want to give the session cookie)

Applying your code I made the following code in set.php.

<?php session_set_cookie_params(0, '/', ''); session_start(); $_SESSION[-'mySession_name'-]='mySession_Value'; ?>

And the following code is in echo.php.

session_set_cookie_params(0, '/', ''); session_start(); echo $_SESSION[-'mySession_name'-].'[br]';

And the code below is in unset.php.

session_set_cookie_params(0, '/', ''); session_start(); unset($_SESSION[-'mySession_name'-]);

Expecting the output “mySession_Value”, I open the echo page at after opening the set page at,
However the echo page at does not output " “mySession_Value”.

I think I misunderstood your code and made wrong code.

Could you, please, correct my code in each page above?

well for starters, get rid of the -'s inside the brackets. $_SESSION[‘mySession_name’] would be the correct way to reference it.

Try putting this into your echo script:

session_set_cookie_params(0, '/', '');
echo $_SESSION['mySession_name'].'<br>';

and see what it tells you in each subdomain.

Thank you very much.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.