Quick Tip: Drupal Sessions for Anonymous and Authenticated users using $_SESSION

Drupal has a custom session handler that allows for handling of standard PHP session $_SESSION['key'] = 'value' for anonymous and autheticated users as well.
This session declared as above would persist from page to page. So, the above trick is helpful and you would not have to resort to cookies to store some information that stays from page to page (like when implementing multi-step form).
Sometimes, the standard $_SESSION may not work? Why?
Check out your users table. User table with uid 0 may be missing. Drupal uses this user with uid 0 for handling sessions for anonymous users. This comes by default, so if you lost it, please put it back again.
Great tip
Mon, 04/05/2010 - 23:31 — Anonymous
This was good tip !
Regards
I didn't know about uid:0 being crucial on Drupal (I actually deleted it).
Sun, 05/09/2010 - 13:58 — Anonymous
I didn't know about uid:0 being crucial on Drupal (I actually deleted it).
Thx a whole bunch for your site!
Eddie
$_SESSION can be used for many things
Wed, 05/12/2010 - 22:47 — Anonymous
This is a good use of $_SESSION and there are many others within the same scope. I think this is one of the better ways to do this task.
Regards,
This is a good use of $_SESSION
Tue, 08/03/2010 - 03:17 — Anonymous
This is a good use of $_SESSION and there are many others within the same scope. I think this is one of the better ways to do this task.
Regards,
- Log in to post comments