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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use CGI::Cookie; For Cookies

Status
Not open for further replies.

bretttt

Programmer
Jul 23, 2002
74
0
0
US
Hello, I have

use CGI::Cookie;
$in = new CGI;
$coname = $in->cookie ( -name => 'iboostuser' );
$copass = $in->cookie ( -name => 'iboostpassword' );

It reads the cookies and works fine......

How can i also set a cookie using use CGI::Cookie;
I am currently setting them with cookie-lib.pl but am having problems with that.

Thanks.
 
Aren't cookies a part of the standard CGI.pm?

--Paul
 
The following are 2 scripts I have written for setting / reading cookies :

#########################################
SET COOKIE

sub func_cookie_set {
use CGI qw/:standard/;
use CGI::Cookie;

# Create new cookies and send them
$cookie1 = new CGI::Cookie(-name=>'screenconceptsusername', -value=>$FORM{"username"});
$cookie2 = new CGI::Cookie(-name=>'screenconceptspassword', -value=>$FORM{"password"});
print header(-cookie=>[$cookie1,$cookie2]);
}
1;
#########################################

#########################################
READ COOKIE

sub func_cookie_read {

@rawCookies = split (/; /,$ENV{'HTTP_COOKIE'});

foreach(@rawCookies) {
($key, $val) = split (/=/,$_);
$cookies{$key} = $val;
}

}
1;
#########################################

I hope this helps - feel free to drop me a note for further info if required.

Nigel Wilson
"kiwi-kid"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top