Title: Storing array in session
Last modified: November 3, 2016

---

# Storing array in session

 *  Resolved [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/storing-array-in-session/)
 * I’m trying to handle the contents of an array, before I store the array within
   a session the array outputs as follows;
 *     ```
       Array
       (
           [0] => yes
           [1] => no
       )
       ```
   
 * However after storing in $wp_session[‘test_array’] it outputs like;
 *     ```
       Recursive_ArrayAccess Object
       (
           [container:protected] => Array
               (
                   [0] => yes
                   [1] => no
               )
   
           [dirty:protected] => 1
       )
       ```
   
 * Is there any advise on returning the array to it’s original format so I can handle
   it easily.
 * Thanks JD

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/storing-array-in-session/#post-8403269)
 * Could you serialize() the array before you store it, and unserialize() it when
   you retrieve it.
 *  Thread Starter [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/storing-array-in-session/#post-8432630)
 * [@lorro](https://wordpress.org/support/users/lorro/), cheers, very straight forward,
   I was certainly trying to overcomplicate it. Thanks for pointing me in the right
   direction.
 * ^JD

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Storing array in session’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [session](https://wordpress.org/support/topic-tag/session/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jduffell](https://wordpress.org/support/users/jduffell/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/storing-array-in-session/#post-8432630)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
