Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > problem to retrieve cookie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-15-04, 01:24
stevencl2000 stevencl2000 is offline
Registered User
 
Join Date: Mar 2004
Location: Malaysia
Posts: 29
Angry problem to retrieve cookie

I have this program, where it can set the cookie, and produce the header like:

Set-Cookie: student_login=pearloh; path=/ Date: Tue, 15 Jun 2004 04:13:38 GMT Content-Type: text/html; charset=ISO-8859-1

i have set the cookie in perl this way:

my $student_cookie = cookie(-name => 'student_login',
-value=> $student_login);
print header(-cookie =>$student_cookie);


but, the following web page after this page, cant seemed to retrieve the cookie...

<td width="20%">
<div align="left">
<font color="#ffffff" size="1"><b>
<font face="Verdana, Arial, Helvetica, sans-serif">
$student_login Answer</font></b></font></div>
</td>


Please HELP...
Reply With Quote
  #2 (permalink)  
Old 06-15-04, 03:20
reneeb reneeb is offline
Registered User
 
Join Date: Jan 2004
Location: Germany
Posts: 167
You have to get the cookies' value. You can do like this:

skript1:
Code:
#! /usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = CGI->new(); my $cookie = $cgi->cookie(-name => 'student_login', -value => $student_login); print $cgi->header(-type => 'text/html', -cookie => $cookie), $cgi->start_html(), $cgi->h2('The cookie is set'), $cgi->end_html();

skript2:
Code:
#! /usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = CGI->new(); my %cookie_values = $cgi->cookie('student_login'); print $cgi->header(-type => 'text/html'), $cgi->start_html(), $cgi->h2("The cookies' value is ".$cookie_values{value}), $cgi->end_html();
__________________
board.perl-community.de - The German Perl-Community
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On