Welcome Guest, Not a member yet? Register   Sign In
Problem with updating session data

(06-14-2016, 05:54 AM)boddah85 Wrote: I created my own authantication library. I'm using database session driver and I've added one column to original table named 'user_id'.  I'm trying to update session table with query :

[3] => UPDATE `ci_sessions_2` SET `user_id` = '1' WHERE `id` = 'blabla_sessioncode'

It works when user is logging in but not when session expires and user is back (and had 'remember me' checked).

$this->db->queries print this query every time, there no database errors and when I copy query and manually paste to phpmyadmin it works.

What are you expecting to happen? What is happening?

Why are you storing the user ID in the session as well as in a separate column in the session table? What is the purpose of modifying the session table in the first place?

The session is temporary, and an expired session should eventually be deleted by the system, but may stay in the table for an indefinite period of time. In some instances, depending on the way the database table is defined and the configuration of the database itself, you could be prevented from setting the same user_id value on multiple rows in the table. Since expired sessions may sit in the table for some time before the system deletes them, you would have to remove the other sessions which use the same user_id before you would be allowed to update the row for the current session.

In most cases, you're just creating a headache for yourself by modifying the session table and storing the user_id there. The session should be transient, and anything that needs to be persisted should be stored in the database, not in the session.

Messages In This Thread
Problem with updating session data - by boddah85 - 06-14-2016, 05:54 AM
RE: Problem with updating session data - by mwhitney - 06-14-2016, 09:34 AM
RE: Problem with updating session data - by PaulD - 06-14-2016, 03:50 PM

Theme © iAndrew 2016 - Forum software by © MyBB