Well, it doesn't work best, and it's logical.
The problem isn't that the data in variable session are wrong or corrupted, the problem is the data are rewrote when you leave category template for item template.
So, I putted in category_items.php:
Code:
$session = JFactory::getSession();
$mydata =time();
echo $mydata;
// Make data safe for DB storage
$mydata_safe = base64_encode(serialize($mydata));
// Store data into session
$session->set('myvariable', $mydata_safe, 'myarea');
and it print 1390752334 to the screen of category view.
I putted in item.php :
Code:
// Get session object
$session = JFactory::getSession();
// Get data from session
$mydata_safe = $session->get('myvariable', 'default_value', 'myarea');
// Decode / unserialize data
$mydata = unserialize(base64_decode($mydata_safe));
echo $mydata;
and it print 1390752356 in the item view.
The content of 'myvariable' has been rewritten when I have clicked on item link.
And I not only have used time(), but also a random value in a array.
The conclusion is that category_items.php is reused when you click on a item link.