cranberry13 has asked for the wisdom of the Perl Monks concerning the following question:
I tried logging in and it worked and saved the cookies properly. I also tried creating a new user and it too saved the cookies properly, etc -- at least it appeared to be doing these things.
I didn't touch the login program. Last night I wanted to test a different part of the membership program. I logged in like I normally do, and it takes me to the menu page and prints out who I am along with the user id. But if I click on any of the links (ie. update profile, add an event, etc)it says that I am not logged in(!). I tried different user names, etc and I also tried creating a new profile (userid/password) ... it says that I'm not logged in though. I never touched the login program and I checked the settings for cookies on my computer ... everything looks good.
I am attaching the login program and also the subroutine that 'gets' the userid from the cookies.
Any ideas why the program suddenly went bezerk?
The problem must be either the way the cookies are set or the way they are beign retreived and read.
########################################################## ## THIS PROCEDURE MAKES SURE THAT THE USER IS LOGGED IN ########################################################## sub CheckIfUserIsLoggedIn { use CGI::Session; my ($sid,$session,$userid); $cgi=new CGI; $sid=$cgi->cookie("CGISESSID")||undef; $session = new CGI::Session("driver:DB_File",$sid,{Directory=>'/tmp'}) +; $userid = $session->param("userid"); if ($userid eq "") { print "Content-type: text/html\n\n"; print "You are not logged in!! $userid\n\n"; exit; } else { return $userid; } } #################################################### The code below is from the login.pl routine that sets the cookie after + checking that the password and username match what is in the DB: ## If the username and password are correct, then set cookie a +nd proceed if ($r[0] eq $psswd) { $cgi = new CGI; $session = new CGI::Session("driver:DB_File",undef,{Di +rectory=>'/tmp'}); $sid=$session->id(); $session->param("userid",$r[1]); $cookie=$cgi->cookie(CGISESSID=>$session->id); print $cgi->header(-cookie=>$cookie); $sesname=$session->param("userid"); $content = &Get_Account_Manager_html($r[1],$r[2],$r[3] +); ## we pass the userid $content = "<b>userid:$sesname</b>".$content; &PrintWebpage($content,"yes"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with cookies
by moot (Chaplain) on Feb 28, 2005 at 22:11 UTC | |
|
Re: Problem with cookies
by tphyahoo (Vicar) on Mar 01, 2005 at 10:12 UTC |