Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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:


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.


fx Edited by boo_radley : closed <b> tag

  • Comment on Writing web pages in Perl with sessions

Replies are listed 'Best First'.
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.


      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, 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. =)


        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...


Re: Writing web pages in Perl with sessions
by arashi (Priest) on Sep 12, 2001 at 17:37 UTC
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....


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://111884]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-05-25 13:14 GMT
Find Nodes?
    Voting Booth?