powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
Hmm, somehow my post did not work. I guess I was not logged in.... Sorry if it gets posted a second time. I cannot find it anywhere! Sorry.....
Help me please.....
I have a kind of predicament! I created a site that is using Apache::Session::MySQL,
it works very well. Then I created another, that works too. So I now created a third,
that uses the very same scripts, and it worked too, but now it does not work.
Here is what it is doing....
It is creating the _session_id;
It is also creating the cookie and passing it to the browser;
The browser then passes it back and forth to the site no matter what page you visit, I
verified that it is not merely creating a different session for every page. it is
remembering the session "id" from page to page. However, it will not store any data into
it;
When I "login" on the other sites, it keeps me logged in until I click logout, then it
deletes the cookie and the session. On this site, when I login and change pages, it says
I'm NOT logged in! so I go login, and it says I was successfully logged in, and it does
get my real name out of the 'registered_users' MySQL database, as well as the last time
I logged in. It displays those for me.
So I know it works, because when I have it log me in, when it shows it is successful,
it is first checking the $sess_ref->attr("login") to make sure it is set to 1, if it is,
then it knows I was successfully logged in. But if it is not then it says something went
wrong, but I never get that message, it always says I was successfully logged in.
So why does it "lose" the information when I leave the page, using the same session_id?
The Cookie stays in tact.
Oh yeah, I also have the site check to see if the user does not have cookies turned on,
if not then the site adds &sess_id=$sess_id to every link, after the ?pg=page_name. So
I forced my browser to reject the cookie, and started a brand new session, which was
then added to every link at the end of the link, and every form as a hidden field.
So I did make sure it was in everything I went to, and when I logged in, it again said
successful, but when I changed pages, with the same sess_id added to the link, it again,
said I was not logged in, so I know that the sessions are somehow not
working(holding session variables).
I deleted the sessions table and recreated it, but it's not working. I'm sooooo lost.
I learned these things(Apache::Session) from the book, "Perl and MySQL for the Web" by
Paul DuBois. I cannot find any help with the Apache::Session module, the docs don't have
any kind of trouble shooting, and no site or list to get help. Can someone, PLEASE help
me, or point me in the right direction?
I would really appreciate the help.
Thank you, very much for any help you can be!
Richard.
Re: Apache::Session::MySQL Help... Please
by perrin (Chancellor) on Dec 28, 2002 at 17:25 UTC
|
You need to debug. We can't really help you much if you don't post a small example of code that is failing. To find out where it's failing, either run it in the debugger or use print STDERR statements to log what's going on. Verify everything, i.e. does the cookie variable really get the cookie in it, does your database connection really connect, etc.
99% of all Apache::Session problems come from people either failing to connect to the database and not checking the return values from DBI->connect or not letting the tied session variable go out of scope. Check for those problems first. | [reply] |
|
|
Yes, that database is connecting, and the cookie is being left. All the cookie holds is the session_id, I have MySQL hold everything else.
I have the same problem, even when I disable cookies and the sites just passes the session_id from page to page.
I have tracked it down to the following problems....
Thank you,
Richard.
Edit by tye, change PRE to CODE tags, add READMORE
| [reply] [d/l] |
|
|
I can't be sure without seeing the code for FRHWebDB::Session, but it looks to me like you have a scoping problem. You've made your session variable global, so it doesn't go out of scope until Perl shuts down. You should try making it lexically scoped (my) and let it go out of scope at the end of your CGI. Or you can do a quick fix by setting it to undef at the end.
By the way, you don't need to explicitly exit at the end of a CGI, and it hurts portability to mod_perl, so leave that out.
| [reply] |