Quote from: OpenGeek at Apr 14, 2011, 09:01 AM
If you access the same domain / session cookie it should work fine... 
That’s what I’d have expected too! But I just can’t get $_SESSION variables working within contexts other than the default context?
Here’s a simple test I set up to prove the point...
Create a snippet ’sess_init’:
<?php
$_SESSION['pageid'] = $modx->resource->get('id');
?>
Create a second snippet ’sess_print’:
<?php
$_SESSION['pagelist'][] = $_SESSION['pageid'];
print_r($_SESSION['pagelist']);
?>
Call these 2 snippets in the page template eg.
<body>
[[!sess_init]]
[[!sess_print]]
</body>
When the page is displayed in the browser, first time through it should print something like:
(where 1 is the current page ID)
Then every time you refresh, it will increment the array with the same page id:
Array ( [0] => 1)
Array ( [0] => 1 [1] => 1)
Array ( [0] => 1 [1] => 1 [2] => 1 )
This works fine within my default web context, but if I try it within any other context, the array doesn’t increment and every time I refresh the page I get the same:
(where 5 is the ID of the page in my other context)
As the contents of $_SESSION[’pagelist] can’t be retrieved it is reinitialising the array each time instead of incrementing it.
Hope this explains the problem better? FYI:
MODx version 2.0.8-pl
PHP version 5.2.17
mysql version 5.0.91-log
Cheers, Dave