I'm writing a script to authenticate a user on initial log in and have this authentication last for 10 minutes (during which it will be passed between scripts) so as to avoid repeated calls to an Exchange server.
I'm creating a session file to store the authentication details and I want to keep the session ID in a cookie, so it can be reloaded each time.
I've got the following...
# load CGI information
$cgi = new CGI;
# load session (from cookie) or create new one if not found
if ($session = new CGI::Session(undef, $cgi, {Directory=>$SESSION_DIR}
+)) {
# expire after 10 minutes
$session->expire('+10m');
# set cookie
$cookie = $cgi->cookie(-name => "CGISESSID",
-value => $session->id,
-expires => '+1h',
-secure => 1);
print $cgi->header(-cookie=>$cookie);
# print opening HTML
print $HTML_OPEN;
if (defined $session->param('authentication')) {
# user is authorised - allow access to site
print "Welcome back"; # D
...
} else {
# authorise user
if (&authorise_user) {
print "Welcome";
# set user info in session file
&log_state($session, 'authentication', 'passed')
} else {
print "You are not welcome";
}
}
But it won't create a cookie on my machine.
Any ideas?
A
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.