I have the following code in a custom module to save a session_id for comparison after logging in. I want to add it to the user object, so I called hook_user like so:
function mymodule_init() {
global $user;
if ($user->uid == 0 && !isset($_SESSION['anonymous_session_id'])) {
$_SESSION['anonymous_session_id'] = session_id();
}
}
function mymodule_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'load':
$user->anonymous_session_id = $_SESSION['anonymous_session_id'];
break;
default:
break;
}
}
However, it is not in the user object. There is a 'session' field that has a serialized array of $_SESSION information, which would mean I probably don't need hook_user, but why isn't this code working?