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

trying to set cookie without cgi->header...my page redirects...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
hello!

i'm trying to set a cookie value, then redirect my page, but i can't seem to find any information on how to do this.

here's my code:

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

#set cookie here

print "Location: [URL unfurl="true"]http://newurl.com\n\n";[/URL]

only thing i can find is how to set it with the header...

besides setting it that way, then calling a javascript redirect, is there another way?

thanks!

- g
 
Code:
print $q->header (
   -cookie => $cookie,
   -location => "[URL unfurl="true"]http://newurl.com",[/URL]
);

Or print the cookie header manually, they look like this:

Code:
Set-Cookie: RMID=732423sdfs73242; expires=Fri, 31-Dec-2010 23:59:59 GMT; path=/; domain=.example.net

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Another way to do it is with redirect.

Code:
my $cgi = CGI->new();
my $cookie = $cgi->cookie(-name => 'mycookie', -value => '1');
print $cgi->redirect(-uri => '[URL unfurl="true"]http://www.google.com/',[/URL] -cookie => $cookie);

Scott Prelewicz
Web Developer
COMAND Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top