Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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");


Comment on Re: try to send cookie and redirect
Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-07-29 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls