"Robert TV" <> writes:
> I got the basic coding from perdoc on the usage of use CGI::Cookie. The main
> examples show an expiry of '+3M' which they say means 3 months. I would
> like my cookie to expire after 10 minutes. Does anyone know the equivalent
> value? I cannot locate any other info in perdoc on this issue.
I don't want to be too snarky, but in the *very same sentence* where
CGI::Cookie's docs explain that +3M means 3 months in the future, it
says: "-expires accepts any of the relative or absolute date formats
recognized by CGI.pm . . .". It also refers you to CGI.pm's documentation
in the very next sentence. I'm hard-pressed to see how you could have
missed this.
> Another question I would like to ask is ... if a cookie is expired,
> will it still return data if fetched? Can Perl read the cookie and
> determine its expiry time and print that data to screen?
This isn't a specifically Perl question; the answer would be the same
if you were coding in PHP or Ruby. That's not a slam, by the way;
partitioning a problem correctly is not always simple. Anyway, read
RFC2109 for the answer, or ask on comp.infosystems.
www.authoring.cgi,
where it's at least on-topic for the group.
> I am trying to build a timeout subroutine for my program. When a user logs
> in, a cookie is set for 10 minutes. Each primary subroutine of the program
> will check the cookie to make sure its not expired and data is being
> returned, if not, user is directed back to login page. I am doing this to
> prevent bookmarking of the software once logged in.
Sorry, that's not going to help much. Cookie expiration times are
tracked on the client, not the server, and a malicious user-agent
could easily ignore the cookie's Max-Age setting. There are better
ways to go about this; I suggest you ask around in CIWAC, where that
sort of thing is more appropriate.
> If the cookie had not expired, it writes a new 10 minute cookie then
> shows the relevant dat for that section/subroutine.
I think you have a minor, but basic misunderstanding of how cookies
work. Asking around on a newsgroup where they discuss such things
would probably help clear things up.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.