Serializing is the conversion of any PHP variable to a string representation of that variable.
Such strings can be stored in a database, session etc.
Let's take a array as an example:
Code:
array (
'key1' => 'value1',
'key2' => 'value2',
)
A serialized version of that array might look like:
Code:
a:2:{s:4:"key1";s:6:"value1";s:4:"key2";s:6:"value2";}
You don't really need to be able to read this, but know that it can be stored.
unserializing that string would give us:
Code:
array (
'key1' => 'value1',
'key2' => 'value2',
)
Your example: it shows an application that has stored a serialized version of a shopping cart in the session (and then retrieved it and unserialized it). Which is kinda silly, as you can store unserialized data in $_SESSION as well.
Bookmarks