in reply to CGI::Session - non-stop session creation problem

How do you determine someone is logged in or not?

if ($sid) { $session = CGI::Session->new(undef, $sid, {Directory => 'c:/apache/s +essions'}); if (! logged_in($session)) { $session->delete(); } }

Or something like that.

Replies are listed 'Best First'.
Re^2: CGI::Session - non-stop session creation problem
by Stenyj (Beadle) on Apr 06, 2005 at 04:06 UTC
    Is that an efficient way of handling it though? Seems unecessary & a waste to create and then immediately delete a session every time a page is loaded, unless the user is logged in.

    I appreciate the feedback. Keep it comin' :-)

    Stenyj

      Put your sessions on a fast disk. Your operating system and/or filesystem cache and/or hard disk cache will optimise this away to never touching your hard disk.

      I insert another layer. Using CGI::Session::DB2, I have the hard disk cache, the filesystem cache, the database cache, and probably something else I'm missing, all pretty much keeping me safe. ;-)

      Also, I'm not even sure that CGI::Session will save anything if the session is deleted immediately like this - it should save during the destruction of the object, where you've already marked it for deletion. So, even though the above says that your physical disk is never touched, this says it likely isn't even asked.