Forum Moderators: coopster
Can you encode and decode multi-dimensional arrays? I think encoding them works just fine using session_encode(), however, session_decode is only capable of decoding the single dimensional arrays stored in the encoded string...
Any ideas?
serialize() handles all types, except the resource-type. You can even serialize() arrays that contain references to itself. References inside the array/object you are serialize()ing will also be stored.
however, session_decode is only capable of decoding the single dimensional arrays stored in the encoded string
session_decode() [php.net] will completely repopulate your session with the string you pass to it. For example, let's say you used session_encode() [php.net] to store a session in a string variable and you write that string out to a file. Later, you can retrieve the contents of that file and after you start_session() you can use the decode function on that string and it will populate your $_SESSION again for you, including multi-dimensional arrays.
session_encode/session_decode is different from serialize/unserialize in that is specific to the $_SESSION superglobal, but that is really about the only difference.