By Fusion_Sushi on
I'm still trying to intagrate Drupal with my other non-Drupal scripts and my solutiuons of passing vars through url and forms does not cut it. I need to know how to read Drupal's cookie login. If you could please let me know how to tell if a user is logged in, I'd appreciate the pointer.
Comments
my results
So far this is what I've been able to find:
PHPSESSID is the name of the cookie for the session. Each time you login you get a new PHPSESSID but when you log out, your PHPSESSID stays the same, even after closing the browser window. You can get the UID from a query to the sessions table on the PHPSESSID.
I wonder why there is not a difinitive, logged in or logged out field?? does that exist?
user object
$GLOBALS['user'] has all about a user. If that object has a uid > 0, the user is logged in.
is it possible to ad and/ or
is it possible to ad and/ or edit some variables of $user?
Are there some functions from drupal?
thanks
My research suggests (meaning
My research suggests (meaning I'm replying from research I've found just now) that data can be appended to a user, permanently, by calling
later, calling
$a = $user->new_property;will assign the saved value to $a
You actually do it like
You actually do it like this:
See http://api.drupal.org/api/function/user_save/6 for more info.
to me doesn't work
it doesn't have any contents ... I use Drupal 6.8
Likely not PHPSESSID
Hi,
I believe PHPSESSID is PHP's default cookie name to store session key. However, Drupal renames this to SESS+md5 hash of the session name (from host domain URL or cookie_domain setting in settings.php file). For example, Drupal.org has SESS2e1f196265529fc19e657f0d379eaed9 for cookie name.
Marc
Drupal7 now uses this rather
Drupal7 now uses this rather than md5:
substr(hash('sha256', $cookie_domain), 0, 32)
It's in configs so you can
It's in configs so you can use
Heshan Wanigasooriya
Github
session_name()
You can also return the current session name with:
session_name();Example