Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Think about Loose Coupling
 
PerlMonks  

Re: Apache::Session hangs

by converter (Priest)
on Mar 02, 2002 at 13:03 UTC ( #148811=note: print w/ replies, xml ) Need Help??


in reply to Apache::Session hangs

This is probably not directly related to the problem you're experiencing, but for what it's worth, the Apache::Session documentation says:

When Session encounters an error, it calls die(). You will probably w +ant to wrap your session logic in an eval block to trap these errors.

He's not kidding. If you supply the TIEHASH method with either a funky session ID, or a session ID for which there is no session in the store, Session dies. Do something like this to handle potential exceptions:

eval { tie %session, 'Apache::Session::File', $session_cookie, { Directory => "../data/sessions", LockDirectory => "../data/sessions" }; }; if ($@) { # since the first attempt failed, supply the # undefined value as the session ID argument # so that Session will generate a new session tie %session, 'Apache::Session::File', undef, { Directory => "../data/sessions", LockDirectory => "../data/sessions" } }

Also, since you're a smart Perl developer and you're using taint mode, you'll want to untaint the session ID before passing it to Apache::Session. The session ID is inserted in session filenames and lock filenames, and Perl will raise an exception if you don't untaint it.

Update:

For what it's worth, it doesn't look like Apache::Session has even been tested on Win32. test report.

If you're having a problem with Fcntl, you might look into Apache::Session::Flex, which should allow you to use your own file locking code. You may be able to use File::FlockDir to do most of the work.


Comment on Re: Apache::Session hangs
Select or Download Code
Re: Re: Apache::Session hangs
by Mandor (Pilgrim) on Mar 02, 2002 at 15:09 UTC
    Thank you for your suggestions. While it didn't fix the problem it certainly helps to improve my code (stupid me forgot about taint mode). If anyone has a idea why I encounter the problem (and how it could be fixed) that would make me a real happy man.
Re: Re: Apache::Session hangs
by perrin (Chancellor) on Mar 02, 2002 at 17:25 UTC
    The trouble with your eval here is that it doesn't check to see what the problem was. It could be something totally unrelated to the error that Apache::Session throws, like a full disk or bad file permissions or any number of other things. You can check to see if what's you think it is with something like this:
    if ($@ =~ m#^Object does not exist in the data store#)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-04-20 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls