Function which initialises the UserCookie.
Note user data is stored in the file system seperately from the wiki pages, and is by $UserID. Note UserID value 112 is used as a sentinel value to signify that no data is available in the file system (retrieved by &LoadUserData ). The UserID is normally available from a cookie (retrieved by &InitCookie) User ID value 111 is used as an error value that UserID is out of range. (ie: UserID values start at 200) User ID value 113 is used as an error value signifying the the retrieved cookie and the known user id info is out of sync.
sub InitCookie { %SetCookie = (); $TimeZoneOffset = 0; undef $q->{'.cookies'}; # Clear cache if it exists (for SpeedyCGI) %UserCookie = $q->cookie($CookieName?); $UserID = $UserCookie{'id'}; $UserID =~ s/\D//g; # Numeric only if ($UserID < 200) { $UserID = 111; } else { &LoadUserData($UserID); } if ($UserID > 199) { if (($UserData{'id'} != $UserCookie{'id'}) || ($UserData{'randkey'} != $UserCookie{'randkey'})) { $UserID = 113; %UserData = (); # Invalid. Later consider warning message. } } if ($UserData{'tzoffset'} != 0) { $TimeZoneOffset = $UserData{'tzoffset'} * (60 * 60); }