Welcome Guest, Not a member yet? Register   Sign In
Session library and unserialize() error.
#9

[eluser]MVUG[/eluser]
[quote author="Twisted1919" date="1297281529"]Nope, i did not because i don't do things like this.
I know that all my libraries are up to date, so there is no use to make another install(and is not easy having in mind the complexity of the project).

Though, i extended the Session library like:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Session extends CI_Session{

    public function __construct()
    {
        parent::__construct();
    }
    
    /**
     * Update an existing session
     *
     * @access    public
     * @return    void
    */
    function sess_update()
    {
       // skip the session update if this is an AJAX call!
       if ( ! IS_AJAX )
       {
           parent::sess_update();
       }
    }
    
    // --------------------------------------------------------------------

    /**
     * Serialize an array
     *
     * This function first converts any slashes found in the array to a temporary
     * marker, so when it gets unserialized the slashes will be preserved
     *
     * @access    private
     * @param    array
     * @return    string
     */
    function _serialize($data)
    {
        if (is_array($data))
        {
            foreach ($data as $key => $val)
            {
                if (is_string($val))
                {
                    $data[$key] = str_replace('\\', '{{slash}}', $val);
                }
            }
        }
        else
        {
            if (is_string($data))
            {
                $data = str_replace('\\', '{{slash}}', $data);
            }
        }

        return base64_encode(serialize($data));
    }

    // --------------------------------------------------------------------

    /**
     * Unserialize
     *
     * This function unserializes a data string, then converts any
     * temporary slash markers back to actual slashes
     *
     * @access    private
     * @param    array
     * @return    string
     */
    function _unserialize($data)
    {
        $data = base64_decode($data);
        $data = @unserialize(strip_slashes($data));

        if (is_array($data))
        {
            foreach ($data as $key => $val)
            {
                if (is_string($val))
                {
                    $data[$key] = str_replace('{{slash}}', '\\', $val);
                }
            }

            return $data;
        }

        return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
    }    

}

So now i am base64_encoding/decoding before before serialize/unserialize.
I need to do more tests to see if i receive the error again, if not i'll fill a bug report on this.[/quote]

Why are you base64 encoding/decoding here? There was an issue with CI and the serialize/unserializing of objects... In CI 2.0 this is fixed, check this code out: https://bitbucket.org/ellislab/codeignit...bb586e29d9


Messages In This Thread
Session library and unserialize() error. - by El Forum - 02-07-2011, 11:15 AM
Session library and unserialize() error. - by El Forum - 02-08-2011, 10:49 AM
Session library and unserialize() error. - by El Forum - 02-08-2011, 10:40 PM
Session library and unserialize() error. - by El Forum - 02-09-2011, 05:59 AM
Session library and unserialize() error. - by El Forum - 02-09-2011, 07:47 AM
Session library and unserialize() error. - by El Forum - 02-09-2011, 07:50 AM
Session library and unserialize() error. - by El Forum - 02-09-2011, 07:58 AM
Session library and unserialize() error. - by El Forum - 02-09-2011, 08:12 AM
Session library and unserialize() error. - by El Forum - 02-10-2011, 01:56 AM
Session library and unserialize() error. - by El Forum - 02-10-2011, 01:58 AM
Session library and unserialize() error. - by El Forum - 02-10-2011, 06:19 AM
Session library and unserialize() error. - by El Forum - 02-10-2011, 10:51 PM
Session library and unserialize() error. - by El Forum - 02-11-2011, 06:54 AM
Session library and unserialize() error. - by El Forum - 02-11-2011, 10:17 AM
Session library and unserialize() error. - by El Forum - 02-11-2011, 10:30 AM
Session library and unserialize() error. - by El Forum - 06-16-2011, 12:17 PM
Session library and unserialize() error. - by El Forum - 06-16-2011, 12:32 PM
Session library and unserialize() error. - by El Forum - 06-16-2011, 10:06 PM
Session library and unserialize() error. - by El Forum - 06-17-2011, 01:34 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 02:34 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 02:40 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 05:43 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 05:56 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 06:07 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 06:13 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 08:45 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 09:02 AM
Session library and unserialize() error. - by El Forum - 06-17-2011, 08:33 PM
Session library and unserialize() error. - by El Forum - 06-23-2011, 01:34 AM
Session library and unserialize() error. - by El Forum - 08-25-2012, 12:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB