Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Writing web pages in Perl with sessions

by fx (Pilgrim)
on Sep 12, 2001 at 15:59 UTC ( #111884=perlquestion: print w/ replies, xml ) Need Help??
fx has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

A search for 'session' and 'sessions' on this site has, suprisingly, revealed nothing.

I am trying to find the 'best' way to handle user sessions on the websites I have written in Perl. The current methods involve storing a session ID (20 characters, or something like that) in a database/file and retrieving at the start of every page.

This does not seem efficient.

Are there any better ways to do this? Can I store sessions in memory?

I am not using mod_perl if that matters.

Cheers,

fx Edited by boo_radley : closed <b> tag

Comment on Writing web pages in Perl with sessions
Re: Writing web pages in Perl with sessions
by blakem (Monsignor) on Sep 12, 2001 at 16:07 UTC
    Retry your query at Super Search. The regular search is currently a bit buggy....

    -Blake

Re: Writing web pages in Perl with sessions
by broquaint (Abbot) on Sep 12, 2001 at 16:37 UTC
    I'm no web perl guru, but I've heard on the grapevine that the Apache::Session module could be just you're ticket. It should work even if your not running Apache or mod_perl.
    HTH

    broquaint

      I, too, must advocate the use of Apache::Session. According to a history of the module I read, it has little to do with Apache or Sessions itself and is called "Apache::Session" purely for historical reasons.

      Apache::Session is the underlying framework to implement your own session system. It's basically an interface to an object store. You tie a hash to, lets say Apache::Session::DBI, use your hash as you like, then when you come back with an id of some sort (from a cookie perhaps, or a session url like http://example.com/session/3F48dfj12578w), your hash will be restored.

      The nice thing is that storage methods for files and numerous databases are available. Check out the perldoc on it for some examples. As one who rolled his own session management system before discovering this, I highly recommend using this before reinventing another wheel. =)

      -Ducky

        So, Apache::Session is perhaps the way to go - I shall look at that.

        However, I am still wondering, is there a way to use memory? Surely this would provide quicker storage/access? I seem to remember a particular web-based e-mail client (IMP perhaps?...) using shared memory as a session store...

        fx

Re: Writing web pages in Perl with sessions
by arashi (Priest) on Sep 12, 2001 at 17:37 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-12-27 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls