in reply to problem with CGI::Session / DBI connection

You may want to try adding a $session->close(); at the end of your script to avoid the global destruction (it's what I had to do for CGI::Session::MySQL).

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Replies are listed 'Best First'.
Re: Re: problem with CGI::Session / DBI connection
by punkish (Priest) on Mar 02, 2004 at 14:18 UTC
    You may want to try adding a $session->close(); at the end of your script to avoid the global destruction (it's what I had to do for CGI::Session::MySQL).
    Thanks for the advice, but that is not the problem at all. I have figured that because of my error ("Can't connect....") the session itself is not being created. Nothing is being stored in the sessions table in the database. Since I am passing a valid Handle, the script should connect to my database, and post the session values in the table. But that itself is failing.

    My question has now changed a bit and become thus -- I am looking for advice on session management for web applications. The mechanism should be cross-platform (run at least on Mac OS X and Windows) and cross webserver (Apache and IIS) and integrate with a few cross-platform storage mechanisms (databases). More than anything, the mechanism should be well-supported (at least a well frequented mailing list).

    CGI::Session seems like a wonderful module and I have mostly had luck with it. But there doesn't seem to be a community behind it. There is a moribund-ish mailing list.

    Apache::Session seems to be well-supported (can Google a lot of activity on it), but doesn't seem to be cross-platform (no PPM for Windows).

    Surely this must be a common problem solved by Perl coders on Windows. Any guidance would be much appreciated.

    Update: Never mind. Found Apache-Session ppd on http://theoryx5.uwinnipeg.ca/ppmpackages/ so that might provide me a workaround. Would still like to figure out what is causing CGI::Session to choke. It is a nice, simple module. Too bad I can't find an active mailing list behind it.

      I have figured that because of my error ("Can't connect....") the session itself is not being created.
      Well doesn't this give you a clue? If youare getting this error then the handle _IS NOT_ valid when you pass it in. SOmething somewhere else is possibly closing the ahndle before it is used here.

      CGI::Session works very well on all systems where I have used it (Windows, Linux, Solaris and HP-UX) with severeal different databases, but always with Apache never IIS (except in testing at one site where it currently runs okay on a test bed but was never put into production).

      As for CGI::Session, mail the author, he usually responds very quickly. I think he might also have a wiki or some such on his website.

      jdtoronto

        I have figured that because of my error ("Can't connect....") the session itself is not being created.
        Well doesn't this give you a clue? If youare getting this error then the handle _IS NOT_ valid when you pass it in. SOmething somewhere else is possibly closing the ahndle before it is used here.
        Yeah, while it does give me a clue, it doesn't lead me to the scene of crime ;-). I know it is croaking because the $dbh is not valid. I don't know why $dbh is getting clobbered. I have tried to debug by just doing stuff with $dbh (query, etc.) and it works just fine. Somewhere between creating the handle, and passing it to CGI::Session it is getting clobbered.

        I too believe that CGI::Session is a fine module. It is very well documented (Kudos to the author) with clear to follow examples. The problem is obviously with my implementation/setup. And I need to find the problem. If the mailing list had been active I could have asked for help from an audience focused on CGI::Session. Right now I am floundering.

        Update: Found a part of the solution! Hope this helps others in the same situation. One of my problem was that the database and its enclosing directory both had to have read/write permissions for the "Everyone" group (of which, IUSR_*, the account under which IIS runs, is a part). Further details can be found at http://support.microsoft.com/default.aspx?scid=kb;en-us;q175168. I still have to figure out why the Handle is not being passed to CGI::Session. For now, I have hardcoded the datasource and it works. But doing it the way the module expects it does not work.