Simple Session Support
[resolved] simpleSessionSet($key, array()); (4 posts)

  1. Cristiano
    Posted 2 years ago #

    Hi friends,

    What should I do to work with array() for session $value?

    My session should be: $_SESSION['hashed_urls'][$_url]=$value;
    How to set it using Simple Session Support plugin?



  2. Jules Colle
    Posted 2 years ago #

    I needed the same thing (looks like I'm the most active user of this plugin.. :))

    I modified the Get and Set functions like so:

    function simpleSessionGet($key, $default='') {
        if(isset($_SESSION[$key])) {
            return unserialize($_SESSION[$key]);
        } else {
            return $default;
    function simpleSessionSet($key, $value) {
        $_SESSION[$key] = serialize($value);

    The trick is to save all data serialized in the session, and unserialize it again when you need to retrieve it.

    If you don't like to modify the plugin code (even though I believe the code is more robust with my modifications), you could just call the functions like this: simpleSessionSet($key, serialize($value)) and unserialize(simpleSessionGet($key))

    In you particular case
    would be equivalent to
    simpleSessionSet('hashed_urls', array($_url=>$value));
    if you used the modified plugin code.

  3. Peter Wooster
    Plugin Author

    Posted 2 years ago #

    Thanks Jules,

    Serialization is the way to go, I'll probably add it as an option in the next release. I just completed testing everything for WP 3.8, but I will be making updates to my plugins.


  4. ianarmstrong
    Posted 2 years ago #

    This is such an easy change to make, I'm not sure why you haven't just pushed it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Session Support
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic