Sessions
Posted: Sat Mar 27, 2004 4:34 pm
I have searched about this forum and tried a number of things that have been suggested and I have read a good portion of the manual with regards to sessions and still can't see what I am missing. Could someone cast a critical eye over the following and spot what is probably a stupid mistake?
I am trying to allow a user to choose which currency to use on an ecommerce site and by choosing, set up a session var with a directory value stored in it that I can access to determine which sub site to use. Here is my code from the entry page that is relavent:
On an image link in the page I have for example:
When the user goes to the next page, for instance "/canada/index.php", I have the following code at the top of the page to help with testing:
Now when the user first comes here, the output indicates that $_SESSION['path'] has been set to "/canada".
Now if the user goies to another page in this subsite, the session value seems to be gone or not available. I use the same code as above to test if the value is there and nothing is output. Also, I have a link on all these sub pages to unset $_SESSION['path'] and take the user back to the entry page to choose another currency. The code is:
The session save path is set to /tmp, which exists on the root of my server but not on the doc root of my site, which I assume is correct and the permissions are set correctly.
Anyone have any help for me? I would sincerely appreciate it as this is driving me a bit crazy.
Cheers
Dave
I am trying to allow a user to choose which currency to use on an ecommerce site and by choosing, set up a session var with a directory value stored in it that I can access to determine which sub site to use. Here is my code from the entry page that is relavent:
Code: Select all
<?php
session_start();
if (isset($_SESSIONї'path'])) {
if ($_SESSIONї'path'] == "/canada") {
header ("Location: /canada/index.php");
} elseif ($_SESSIONї'path'] == "/us") {
header ("Location: /us/index.php");
}
}
?>Code: Select all
<a HREF="/canada/index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('currency_page_r4_c2','','/assets/images/index/currency_page_r4_c2_f3.gif',1)"><img SRC="/assets/images/index/currency_page_r4_c2.gif" ALT="" NAME="currency_page_r4_c2" WIDTH="145" HEIGHT="20" BORDER="0" onClick="<?php $_SESSIONї'path'] = "/canada" ?>"></a>Code: Select all
<?php
session_cache_limiter('none');
session_start();?>
<?php
if (isset($_SESSIONї'path'])) {
echo "Session set and Chosen Directory is: " . $_SESSIONї'path'] . "<br>";
} ?>Now if the user goies to another page in this subsite, the session value seems to be gone or not available. I use the same code as above to test if the value is there and nothing is output. Also, I have a link on all these sub pages to unset $_SESSION['path'] and take the user back to the entry page to choose another currency. The code is:
Code: Select all
<a HREF="/index.php" onClick="XMkillCookie('currency')" onMouseUp="<?php unset($_SESSIONї'path']) ?>">SWITCH CURRENCY</a>Anyone have any help for me? I would sincerely appreciate it as this is driving me a bit crazy.
Cheers
Dave