CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Cookie frustrations

 



Ben
Deleted

Aug 19, 2000, 1:07 AM

Post #1 of 1 (652 views)
Cookie frustrations Can't Post

I am trying to write a program that, when accessed, will check to see if a cookie is available.. if not, it will create a new cookie with the variables gained from an Environmental query, and if there is a cookie, it will add the new variable (from Env. query) to the variables already in the cookie.

The code I have written follows, and as far as I can see, seems to be correct and should do what it is supposed to, but doesn't. The program has been tried on two different servers but to no avail.

#!c:\perl\bin\perl.exe -d

use CGI;
use CGI::Cookie;

$cgiobject = new CGI;
$cgiobject->use_named_parameters;

$ID = $ENV{QUERY_STRING};

$cookie = $cgiobject->cookie('aotgidtd');

if ($cookie eq "")
{&nocookie;}
else
{&cookie;}

print<<HTML;
<HTML><TITLE>Planner</TITLE>
<BODY background="/aotg/images/bgdwood.gif">This is the Planner
</BODY></HTML>
HTML

exit;

sub cookie{
$IDcook = $cgiobject->cookie('aotgidtd');
@vars = split(/:/, $IDcook);
push @vars, $ID;
$cookdata = join(':', @vars);
$cookiego = $cgiobject->cookie(-name=>'aotgidtd',
-value=>"$cookdata",
-expires=>'+3M');
print $cgiobject->header(-cookie=>$cookiego);
}

sub nocookie{
$cookiego = $cgiobject->cookie(-name=>'aotgidtd',
-value=>$ID,
-expires=>'+3M');
print $cgiobject->header(-cookie=>$cookiego);
}

Any help with this would be most welcome, and would dramatically reduce the strain on my poor over-worked brain...


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives