Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Some questions about CGI::Session

by Cody Pendant (Prior)
on Apr 22, 2008 at 00:00 UTC ( #682054=perlquestion: print w/replies, xml ) Need Help??

Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

I recently had to create a website with user log-in and log-out etc and decided to Do It Properly and use CGI::Session instead of hacking my own stuff together.

However, I'm a bit puzzled by a few things:

  1. Why is the CGI::Session::Cookbook no longer visible on the distribution page? It has one major error in it (arguments the wrong way around in the call to the init() sub) but on the other hand, it has a 'recipe' which exactly what I need for the user log-in situation. Has it become obsolete or deprecated in some way? I just used the suggested methods with version 4.13 of the module and everything seems fine.
  2. Why is the current release labelled "UNAUTHORISED" in big red letters? That's a bit scary. Is there some kind of dispute between authors?
  3. I can't find any reference in the pod or the Cookbook to a "remember me" session, i.e. the classic checkbox on a log-in form which means you don't have to log in next time. I solved this myself by inventing my own session param and putting:
    if($session->param('_REMEMBER')){ # set cookie with long expiry }else{ # set default cookie which expires on browser close }
    but I was surprised to see that the idea doesn't even come up. Is this just a matter of fashions changing, and the "remember me" checkbox not being much used when the module was first written?
  4. Although there's a driver for saving sessions in a MySQL database, I was a bit surprised to find it just creates an entry with the session id as the primary key and a long string of text with everything else. It's hardly better than the default text-file method. You might as well use dbmopen() or a tied hash. I know you can create your own params, meaning the table would need to change, because I just did so, but surely it would be much more useful to create a proper table with all the vars in their own column? And if I need to tweak the object by adding my own params then I should be smart enough to add my own column?

Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...

Replies are listed 'Best First'.
Re: Some questions about CGI::Session
by bradcathey (Prior) on Apr 22, 2008 at 00:25 UTC


    I'll be honest, I can't really answer your questions, but I noticed your phrase "Do It Properly and use CGI::Session." If you really want to do it properly, use CGI::Application::Plugin::Session which, of course, implies you are using CGI::Application. Anyway, by comparision CGI::Session is clunky. After you use CAP::Session, you'll see what I mean. Session management is a breeze with the CAP flavored approach, almost intuitive.

    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      Once you've been in a Ford, you'll see why wheels are clunky. Rolling is a breeze in cars.
Re: Some questions about CGI::Session
by Anonymous Monk on Apr 22, 2008 at 07:47 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://682054]
Approved by kyle
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2020-07-14 23:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found