Welcome Guest, Not a member yet? Register   Sign In
CI session library BUG?
#1

[eluser]vps4[/eluser]
/* Location: ./system/libraries/Session.php */
line: 270-282

Code:
if (count($custom_userdata) === 0)
        {
            $custom_userdata = '';
        }
        else
        {
            // Serialize the custom data array so we can store it
            $custom_userdata = $this->_serialize($custom_userdata);
        }

        // Run the update query
        $this->CI->db->where('session_id', $this->userdata['session_id']);
        $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));

AND http://ellislab.com/codeigniter/user-gui...sions.html

Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);

the bug is:

Code:
user_data text NOT NULL
when
Code:
$custom_userdata = '';


this line will get error:
Code:
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));

How can I fix it?
change database table to :
Code:
user_data text NULL

OR modify
/* Location: ./system/libraries/Session.php */
like:
Code:
if (count($custom_userdata) === 0)
        {
            $custom_userdata = '';
                        return false;
        }
#2

[eluser]Dam1an[/eluser]
I think this was a delibrate assumption, that you would only need the database to store session data if you
a) have lots of session data
b) Need some sort of security, track if a user is logged in, user_id etc

With your second suggested solution, would that not cause problems trying to fetch the data, as it doesn't exist, so it would deserialize a null query?
#3

[eluser]TheFuzzy0ne[/eluser]
That field should never be NULL anyway, as it should contain data pertaining to the session, such as ID, last activity, user agent and so on. An empty string is NOT NULL, so I don't see the problem.
#4

[eluser]Dam1an[/eluser]
Actually, the CI session data (ID, last activity, user agent and IP address) all have dedicated field, but you make a valid point with the empty string not being null
#5

[eluser]TheFuzzy0ne[/eluser]
You're right. Sorry, that was a bit of an oversight on my part.
#6

[eluser]vps4[/eluser]
[quote author="Dam1an" date="1245083324"]I think this was a delibrate assumption, that you would only need the database to store session data if you
a) have lots of session data
b) Need some sort of security, track if a user is logged in, user_id etc

With your second suggested solution, would that not cause problems trying to fetch the data, as it doesn't exist, so it would deserialize a null query?[/quote]

I just ask for solution, i have not fix it...
#7

[eluser]TheFuzzy0ne[/eluser]
What error are you getting? To my knowledge this is not a bug.
#8

[eluser]vps4[/eluser]
[quote author="TheFuzzy0ne" date="1245110298"]What error are you getting? To my knowledge this is not a bug.[/quote]

I run redux_auth

the error:
Code:
A Database Error Occurred

Error Number: 1364

Field 'user_data' doesn't have a default value

INSERT INTO `sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`) VALUES ('4a6595cfbc2d87aea1453701eb3e219c', '127.0.0.1', 'Opera/9.63 (Windows NT 5.1; U; Edition IBIS; zh-cn', 1245093099)
#9

[eluser]Dam1an[/eluser]
Are you using redux auth 1.4 or 2? As they both have differant schemas for the sessions table
1.4 doesn't have a field for userdata which is wierd :S
#10

[eluser]TheFuzzy0ne[/eluser]
So the problem is with Redux and not CodeIgniter?




Theme © iAndrew 2016 - Forum software by © MyBB