I've been testing the use of the Memcache session handling, and noticed that:
- There are no database writebacks for session information like there is for cache information.
sess_destroy_uid();is not implemented. Isn't that a security problem if a user is disabled while still logged in?
Perhaps there's a reasoning for this that I'm not able to see, but why shouldn't the session information be written back to the database? Is there a performance hit? If the writeback was there, it would be really easy to clear sessions by uid. I bring this up because I need to use the sess_destroy_uid(); function, but am unable to get my code to work when using Memcache session handling.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | sess_destroy_uid-441842-15.patch | 4.15 KB | premanup |
| #12 | sess_destroy_uid-441842-12.patch | 2.97 KB | darren oh |
| #12 | sess_destroy_uid-441842-12_D5.patch | 3.2 KB | darren oh |
| #11 | sess_destroy_uid-441842-11_D5.patch | 1.51 KB | darren oh |
| #10 | sess_destroy_uid-441842-10.patch | 1.38 KB | darren oh |
Comments
Comment #1
matt_paz commented+1
Comment #2
jeremy commentedThe attached patch fixes this by looking up the memcache session by first retrieving the user object from memcache. It then uses this object to destroy the session. Please test.
Comment #3
jeremy commentedWhoops -- the previous patch had a typo. This one should work. Please test.
Comment #4
jeremy commentedThere was a code path where the session id wasn't saved in the user object, causing the sess_destroy_uid() to fail. The attached patch is updated to fix this. It works in all my testing.
Comment #5
jeremy commentedCommitted.
Comment #6
jeremy commentedLink to the commit for reference:
http://drupal.org/cvs?commit=237454
Comment #7
doq commentedOnly one user session (probably latest) gets deleted.
Comment #8
darren ohThis could be fixed by storing an array of session IDs in the user object.
Comment #9
catchThis is related to #791888: sess_destroy_sid() does not remove the session cookie from the user's browser.
Comment #10
darren ohThis still needs to be fixed for situations where a user has multiple browsers, each with a different session.
Comment #11
darren ohPatch for anyone else who still uses Drupal 5.
Comment #12
darren ohModified to prevent accumulation of dead sessions in the user object.
Comment #13
quotesbro commented#12 looks reasonable, I applied it on production site
Comment #14
premanup commentedAs far as I can see if someone updates user's status or password then function filter_user() in memcache-session.inc is called before sess_destroy_uid(). See the user_save() in user.module:
Therefore when function dmemcache_get($uid, 'users') is called in sess_destroy_uid() it can't get $user object ($user == false). Therefore dmemcache_delete($sid, 'session') is not called at all and all session information stay in the session bin.
If I comment out line cache_clear_all($account->uid, 'users') in filter_user() then patch works as expected.
Comment #15
premanup commentedI changed $op in filter_user() from 'update' to 'after_update'. It solves the problem. Here is the new patch.
Comment #16
japerry