in reply to javascript.. perl.. cookie
simple I know but I hope that helps.#!/usr/bin/perl -w use CGI; use CGI::Cookie; use strict; use Dumpvalue; my %cookies = fetch CGI::Cookie; my $q = new CGI; if(%cookies){ dump_ref(\%cookies); }else{ my $this_url = $ENV{'SCRIPT_NAME'}; print $q->header(); ################################################# #pasted code from posting ################################################# print qq* <script language=javascript type="text/javascript"> <!-- function SetCookie(username, value, expires, path, domain){ document.cookie = username + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString() +) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain); } var expiration = new Date(); expiration.setTime(expiration.getTime() + 60000); SetCookie('username', 'Peter', expiration); // --> </script> <br> <a href="$this_url">Check cookies</a> *; exit; } ################################################# #what do we have in there? ################################################# sub dump_ref { my $ref = shift; my $dumper = new Dumpvalue; print $q->header(); print "<pre>"; $dumper->dumpValues($ref); print "</pre>"; exit; }
was expiration suppose to be expires?var expiration = new Date(); expiration.setTime(expiration.getTime() + 60000);
|
|---|