Jump to content

Multidimensional $session


thetuningspoon
 Share

Recommended Posts

I'm trying to use ProcessWire's $session variable to store multidimensional arrays, like I often do with $_SESSION. I can store multidimensional arrays alright, but if I want to change a variable in one of $session's multidemensional arrays, like so:

$session->myArray['one']['two'] = 'foo';

...I am not able to. Is there any way to do this easily with $session, or am I better off just using php's $_SESSION?

Link to comment
Share on other sites

PW also uses $_SESSION, so there's no harm in using it. It's not going to break anything if you use both $_SESSION and $session. But one thing to note is that PW keeps $session variables in a namespace within $_SESSION. So while you can use $_SESSION or $session, you can't access the same variables from them, i.e. $_SESSION['first_name'] will not be accessible via $session->first_name, or the other way around. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...