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: Beginner:
Can't set cookies

 



douge
Deleted

Mar 23, 2000, 9:46 AM

Post #1 of 3 (731 views)
Can't set cookies Can't Post

I'm unable to set a cookie.

Using:

print "Set-Cookie:language=$formdata
{'language'}\n";

Thanks in advance



brian.hayes
User

Mar 23, 2000, 3:58 PM

Post #2 of 3 (731 views)
Re: Can't set cookies [In reply to] Can't Post

Try HTTP:Cookies;


<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>



use HTTP::Cookies;
$cookie_jar = HTTP::Cookies->new;

$cookie_jar->add_cookie_header($request);
$cookie_jar->extract_cookies($response);
</pre><HR></BLOCKQUOTE>

Brian Hayes


Cure
User

Apr 13, 2000, 4:55 PM

Post #3 of 3 (731 views)
Re: Can't set cookies [In reply to] Can't Post

Sending the Cookie to the Browser

Within a CGI script you can send a cookie to the browser by creating
one or more Set-Cookie: fields in the HTTP header. Here is a typical
sequence:

my $c = new CGI::Cookie(-name => 'foo',
-value => ['bar','baz'],
-expires => '+3M');
print "Set-Cookie: $c\n";
print "Content-Type: text/html\n\n";


Recovering Previous Cookies

%cookies = fetch CGI::Cookie;

fetch returns an associative array consisting of all cookies
returned by the browser. The keys of the array are the cookie names. You
can iterate through the cookies this way:

%cookies = fetch CGI::Cookie;
foreach (keys %cookies) {
do_something($cookies{$_});
}


Cure

 
 


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

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