Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: try to send cookie and redirect

by wardk (Deacon)
on Apr 22, 2002 at 22:55 UTC ( #161172=note: print w/replies, xml ) Need Help??

in reply to try to send cookie and redirect

This snippet works in one of my applications just fine, I think it meets your requiremeents for the most part. This is from a web-based login that redirects to the calling script.

Create and set cookie, then redirect.

my $cookie_name = "FOO" . $E . "SID"; my $SID_cookie = new CGI::Cookie(-name => $cookie_name, -value => $sid, -path => '/', -expires => "+2h", -domain => '', ); print "Set-Cookie: " . $SID_cookie . "\n"; print $q->redirect("$redirectURL");

Replies are listed 'Best First'.
Re: Re: try to send cookie and redirect
by Kanji (Parson) on Apr 22, 2002 at 23:12 UTC

    If you used CGI's named arguments-style, there's no need to craft your own 'Set-Cookie' header: redirect will do it for you, just like header.

    print $cgi->redirect( -uri => $new_url, -cookie => $cookie );


Re: Re: try to send cookie and redirect
by Georgio (Sexton) on Apr 25, 2002 at 07:41 UTC

    It works just fine!
    Thanks a lot!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://161172]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2018-06-25 09:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.