Gossamer Forum
Home : General : Perl Programming :

Set a cookie, and still redirect?

Quote Reply
Set a cookie, and still redirect?
Just wondering.. is it possible to set a cookie, and right after, redirect to another URL?

i.e

Code:
my $cookie = $IN->cookie( -name => "PPC3".$ID, -value => "TRUE", -expires => "+1h");
print $IN->header( -cookie => $cookie );
print $IN->redirect ($goto);

The problem I am having, is that as soon as the cookie is set, a header must have been set? It just doesn't seem to want to redirect to the new URL :(

Is there a way around this?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Set a cookie, and still redirect? In reply to
How about the following:

print $IN->redirect( -URL => $goto, -COOKIE => $cookie );

----
Cheers,

Dan
Principal

Virtual Solutions
Quote Reply
Re: [dan] Set a cookie, and still redirect? In reply to
Would that work?

I ended up showing a message, with 'redirecting', and then using meta tags to redirect to the appropriate URL :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Set a cookie, and still redirect? In reply to
Should work. Give it a whirl. Neater than using an intervening redirect page.

----
Cheers,

Dan
Principal

Virtual Solutions
Quote Reply
Re: [dan] Set a cookie, and still redirect? In reply to
Thanks, that did the trick :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Set a cookie, and still redirect? In reply to
Excellent. Unfortunately, as far as I know when I last checked, not documented in the CGI module docs - not explicitly anyways.

----
Cheers,

Dan
Principal

Virtual Solutions
Quote Reply
Re: [dan] Set a cookie, and still redirect? In reply to
Yeah, thats always a bugger. I search for *hours* trying to find out how to do it.. thats why I finally gave up, and just used meta redirects Blush

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Set a cookie, and still redirect? In reply to
FYI if any of your end-users complain about that particular page "hanging" or "timing-out", be aware that there is a security setting in IE called "Allow META REFRESH" that sometimes get's turned off and that keeps the new page from loading.

Spent about an hour trying to de-bug that one Tongue
Quote Reply
Re: [Watts] Set a cookie, and still redirect? In reply to
Thanks, I'll make a note of that.. as I'm sure it will come up at some point :(

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates