• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A problem with hybrid session library - SOLVED :-) ...

Hello Smile

I have just experienced some problems with the hybrid session library (which I chosed because the normal session was almost always clearing its data in a few clicks only) ... and I thought it could be helpful for some of you, guys, if I share my experience with you Smile

So - I'm making a site for a tour of a few singers, and there is a game in the site where the registered and logged users will be able to upload pictures, then the rest of the registered and logged can vote for the pictures, and at the end of the week the top 5 pics win awards. So, it was fine for a couple of days, until we noticed (the developement team) that while you click on the links and browse in the site, without logging in - you suddenly appear to be ..... logged as some other user ... and only a little later we had a complain that he had uploaded a picture and after that the picture was shown to be uploaded by another user ...

So we began working on the problem, and - literally a few minutes ago - we found it out Smile ... the problem was in the session library, in the sess_write() method. At the end you can find the where clause of the update query, which was originally:

$this->CI->db->where('session_id', $this->userdata['session_id']);

but when we saw the table in the database - the sessions of many people had one and the same ids ... ( the "session_id" field ) ... so when the update query executes - many records appeared to be updated with the data that only one of them had in its session. So we changed the code above with this one:

$this->CI->db->where( array( 'session_id' => $this->userdata['session_id'], 'ip_address' => $this->userdata['ip_address'] ) );

and now the updating happens not only upon the session_id, but also upon the ip of the user Smile

And now everything is fine Smile

Hope this help you huys Wink
C ya Wink

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.