Retrieving Server-side Session Data

Like it says on the packet, is it possible to retrieve an array of data from a server-side $_SESSION?

sess_cb558c02d13e45c59c0c13411a4e5dc8 [B]contains[/B] confirm|a:1:{s:7:"display";s:7:"desktop";}
sess_11cb42acaa443b1660a0a2d97976900c [B]contains[/B] confirm|a:2:{s:7:"display";s:7:"desktop";s:5:"email";N;}
sess_bde69c5208e117a5e2e3dde0ef0b6df7 [B]contains[/B] confirm|a:2:{s:7:"display";s:7:"desktop";s:5:"email";s:4:"sent";}

Boy, would I like to get my code around the third one.

Am I chasing my tail here?

$_SESSION is already an array.


session_start();

var_dump( $_SESSION );

If you are trying to be “clever” and do things the long way around by toying with the raw files: http://php.net/manual/en/function.serialize.php

Thanks for that. I didn’t think to dump the array. I’m just trying to keep track of two ‘states’ in the event that a browser is refusing cookies. The array corresponding to that third session is interesting:

array(1) {   ["display"]=>   NULL } array(2) {   ["display"]=>   string(7) "desktop"   ["email"]=>   NULL }

Yet the session cookie array is:

confirm|a:2:{s:7:"display";s:7:"desktop";s:5:"email";s:4:"sent";}

So I guess my code is not asking the right questions here.

I actually use serialize() and unserialize() to store the arrays in proper honest-to-goodness cookies for browsers that accept them. I didn’t realise I could do that with $_SESSION.

NOTE: My apologies, that array of results is all wrong. In fact the session is being stored. I’m just not retrieving it in the code. Thanks again for the debugging advice.