Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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 => '.foobar.com', ); 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 );

        --k.


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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://161172]
help
Chatterbox?
[Lady_Aleena]: 1nickt, I wouldn't, but I'm not normal.
LanX aggrees, LA isn't normal ;-P
[Lady_Aleena]: LanX, thanks bunches.
[Lady_Aleena]: Rigth now I'm ranting in my head about an old subject.
[1nickt]: Hm, that is, how to prevent Perl from turning 1.0 into 1? I feel sure this must be an faq, but am reading perlnum and not finding the answer ...
[Lady_Aleena]: 1nickt, why does it matter in this case?
[1nickt]: Hm, perhaps this? "Operators which expect an integer force the argument into the integer format."
[1nickt]: Can this be? So print
[1nickt]: ... "expects an integer" ?

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2017-05-24 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?