joon1
1
I have some pages like the following.
http://dot.kr/x-test/session/set_session.php
http://dot.kr/x-test/session/echo_session.php
http://dot.kr/x-test/session/unset_session.php
We can see the pages above is at the following.
http:/111./dot.kr/x-test/session/set_session.php
http://111.dot.kr/x-test/session/echo_session.php
http://111.dot.kr/x-test/session/unset_session.php
Each page has the php code below.
[code]set_session.php
<?php
session_start();
$_SESSION[-'mySession_name'-]='mySession_Value';
?>
echo_session.php
<?php
session_start();
echo $_SESSION['mySession_name'].'
';
?>
unset_session.php
<?php
session_start();
unset($_SESSION['mySession_name']);
?>
[/code] I like to make like the following.
if a user opens the echo_session page at http://111.dot.kr/x-test/session/echo_session.php after opening the set_session page at http://dot.kr/x-test/session/set_session.php, the result outputs “mySession_Value”.
Can I do that with your help?
(Please notice, “111.dot.kr” is a subDomain of “dot.kr”.)
First line of code: (Yes, even before session_start)
session_set_cookie_params(0, '/', '.dot.kr');
(feel free to replace 0 with whatever timeout you want to give the session cookie)
joon1
3
Applying your code I made the following code in set.php.
<?php
session_set_cookie_params(0, '/', '.dot.kr');
session_start();
$_SESSION[-'mySession_name'-]='mySession_Value';
?>
And the following code is in echo.php.
session_set_cookie_params(0, '/', '.dot.kr');
session_start();
echo $_SESSION[-'mySession_name'-].'[br]';
And the code below is in unset.php.
session_set_cookie_params(0, '/', '.dot.kr');
session_start();
unset($_SESSION[-'mySession_name'-]);
Expecting the output “mySession_Value”, I open the echo page at http://111.dot.kr/x-test/session/echo.php after opening the set page at http://dot.kr/x-test/session/set.php,
However the echo page at http://111.dot.kr/x-test/session/echo.php 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, '/', '.dot.kr');
session_start();
var_dump($_COOKIE);
echo $_SESSION['mySession_name'].'<br>';
and see what it tells you in each subdomain.
system
Closed
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.