thetuningspoon Posted July 9, 2013 Share Posted July 9, 2013 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 More sharing options...
Wanze Posted July 9, 2013 Share Posted July 9, 2013 This should work: $myArray = $session->myArray; $myArray['one']['two'] = 'foo'; $session->myArray = $myArray; 2 Link to comment Share on other sites More sharing options...
thetuningspoon Posted July 10, 2013 Author Share Posted July 10, 2013 Ok, that's what I thought. I'll probably stick with $_SESSION since it doesn't require the extra steps. Link to comment Share on other sites More sharing options...
kongondo Posted July 10, 2013 Share Posted July 10, 2013 I think this is similar to this? http://processwire.com/talk/topic/691-wireinput-only-allows-one-dimensional-arrays-why/ $input doesn't do multidimensional arrays either...Advice is to use $_POST, etc..in such cases 1 Link to comment Share on other sites More sharing options...
ryan Posted July 12, 2013 Share Posted July 12, 2013 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now