Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Cookies/Session

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
What I want to do is to write to a session variable, but looking at documentation for CGI, i don't see that as an option. I do see HTTP Cookies, so per-session cookie is my next alternative, but still no luck at all. Problem is
1) How do I make the cookie per-session (i.e. not stored in browser)
2) using the following code, nothing is working!

It is not storing or picking up the cookie value!!

Code:
#!/usr/bin/perl -w
use CGI qw(:standard);

$query=new CGI;

$cookieValue = $query->cookie("test") || 999;

$cookieValue++;

$packedCookie = $query->cookie(-NAME    => 'test',
                               -VALUE   => $cookieValue,
                               -EXPIRES => '+1h',
                               -path    => '/cgi-bin',
                               -domain  => '.myWebsite.com');

print $query->header(-type=>'text/html',
                     -cache_control => 'no-cache',
    			     -expires=>'now',
                     -COOKIE => $packedCookie);  

print &quot;<HTML><HEAD><TITLE>Session Cookie Test</TITLE>&quot;;
print &quot;<meta name=\&quot;Pragma\&quot; content=\&quot;no-cache\&quot;>&quot;;
print &quot;<meta name=\&quot;Cache-Control\&quot; content=\&quot;no-cache, must-revalidate\&quot;>&quot;;
print &quot;<meta name=\&quot;Cache-Control\&quot; content=\&quot;no-cache, must-revalidate\&quot;>&quot;;

print &quot;<meta name=\&quot;Expires\&quot; content=\&quot;Thu, 1 Jan 1970 00:00:01 GMT\&quot;>&quot;;
print &quot;</HEAD><BODY>&quot;;



print &quot;cookie value is [&quot;;
print $cookieValue;
print &quot;]<br>&quot;;
print &quot;</body></html>&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top