ericmann/wp-session-manager — pull request #13 by mgmartel (2013-10-08 08:53:32+00:00)
Title: Better handling of multidimensional arrays

First of all: thanks and kudos for creating this plugin. Fills a huge gap in the WP universe for many projects!

Currently, the whole session object is serialized and written to the DB as is, after a check of the session object being dirty. This has some problems:

* Any arrays in the session are stored as (serialized) Recursive_ArrayAccess objects, which makes them retain their dirty state from when they were first created.

* When checking for internal changes, only the top-level object gets checked - so even if the above would not be true, you could go ahead and change child arrays around, without the changes ever being written to DB.

### Solution ###

* Store $session->toArray() in the options table

* Make Recursive_ArrayAccess automatically transform child arrays to Recursive_ArrayAccess objects

* Implement a recursive Recursive_ArrayAccess::is_dirty() check, that checks for internal changes in each child array.