neptun_
Aug 17th, 2009, 04:46 AM
Hi,
I am using a page with an iframe within it.
When I am loading the first time the page, I change the session name. The problem is that I do not know how to pass the new session name also to the IFrame.
The beginning of the code for the page is:
global $session_name;
if (isset($_REQUEST['session_name'])) {
// use session name passed via $_GET or $_POST
$session_name = $_REQUEST['session_name'];
} // if
// get details from any previous session
if (isset($session_name)) {
// use existing session name
} else {
// assign new session name
$session_name = getNewSession('session');
} // if
session_name($session_name);
session_start();
echo ">" . $session_name;
function getNewSession ($prefix = 'session')
// create a new session name using $prefix + a number.
{
// step through numbers 0-99
for ($i = 0; $i <= 1000; $i++) {
$session_name = $prefix .$i;
if (!array_key_exists($session_name, $_COOKIE)) {
break;
} // if
} // if
return $session_name;
} // getNewSession
The beginning of the code for the IFrame is:
session_start();
echo ">>" . session_name();
For the page, the output is : >session0
For the IFrame the output is : >>PHPSESSID
The conclusion is that, in this case, the IFrame doesn’t know about the session name of the parent page.
Could you suggest me an idea on how to make them work together, by using the same session name?
Thanks
I am using a page with an iframe within it.
When I am loading the first time the page, I change the session name. The problem is that I do not know how to pass the new session name also to the IFrame.
The beginning of the code for the page is:
global $session_name;
if (isset($_REQUEST['session_name'])) {
// use session name passed via $_GET or $_POST
$session_name = $_REQUEST['session_name'];
} // if
// get details from any previous session
if (isset($session_name)) {
// use existing session name
} else {
// assign new session name
$session_name = getNewSession('session');
} // if
session_name($session_name);
session_start();
echo ">" . $session_name;
function getNewSession ($prefix = 'session')
// create a new session name using $prefix + a number.
{
// step through numbers 0-99
for ($i = 0; $i <= 1000; $i++) {
$session_name = $prefix .$i;
if (!array_key_exists($session_name, $_COOKIE)) {
break;
} // if
} // if
return $session_name;
} // getNewSession
The beginning of the code for the IFrame is:
session_start();
echo ">>" . session_name();
For the page, the output is : >session0
For the IFrame the output is : >>PHPSESSID
The conclusion is that, in this case, the IFrame doesn’t know about the session name of the parent page.
Could you suggest me an idea on how to make them work together, by using the same session name?
Thanks