Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Problems getting session management to work: is_expired seems to lie to me

by Anonymous Monk
on May 06, 2013 at 19:47 UTC ( #1032391=note: print w/replies, xml ) Need Help??

in reply to Problems getting session management to work: is_expired seems to lie to me

... much unrelated code ... Any ideas?

What I would do is write a program like Re^3: CGI::Session - expiry and Re^3: CGI::Session - expiry to answer one or two clear and explicit questions

  • Comment on Re: Problems getting session management to work: is_expired seems to lie to me

Replies are listed 'Best First'.
Re^2: Problems getting session management to work: is_expired seems to lie to me
by ted.byers (Monk) on May 06, 2013 at 21:06 UTC

    Yes, yes, you point to trivial programs that run from the commandline, but those specific scripts will not work as CGI programs as they do not write the usual suite of headers, or valid HTML, to standard out. The fact is that in a number of cases, I have found the behaviour of certain code snippets differing based on whether executed from a commandline script or from within a CGI script. This is why I included all that was necessary to have apache use perl to create the output page, and also why code of the sort you recommend can not answer the question. The code I posted is trivially simple (about 60 lines in the package and about 30 in the cgi script, hardly qualifies as much unrelated code - and in fact most of the code in the pl script is what is necessary to create a valid CGI script - and yes, you need not look at the code in the package unless you're interested in error handling in that context - but it makes the output of the CGI script more interesting), but it is sufficient to provide a trivially simple context in which the value returned by is_expired is wrong. The code in the posts you provided illustrates how is_expired is supposed to work, and that is something I already understood. What I did not understand, and the specific question you ignored, is why it did not work that way when applied in a more realistic context.

    To see the code I posted in action, all that need be done is put it in the cgi directory for your web browser, request the page using your favourite browser, and then request once, in less than 5 minutes, to see what ought to happen when the session ought not have timed out, and then wait a little over 5 minutes (something that the impatient can adjust without difficulty) to see what happens when the session ought to have expired.

    And yes, I am familiar with the notion of small, self contained, programs that illustrate the problem, and the code I posted IS small, self contained, and shows the problem where the code you recommend, while small and self contained, is not adequate to illustrate the problem because they would have to be singificantly altered in order to be executed as a CGI script. The relevant criterion that makes the code I posted applicable is that it shows the problem. Now, as I do not know why the problem exists, it could be anything from some peculiarity in the Activestate distributions, or running it on Windows, or anything else that I can't yet imagine, but information that will tell me what is the cause is what is needed here; nothing else.

    Do you have any information that might actually address the real problem?



        Look again. A new session is created in the second half of the conditional block in my script. A new session is crated only the first time the page is accessed, which I can detect based on whether or not $cnt is defined.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032391]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-06-24 19:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.