Gossamer Forum
Home : General : Perl Programming :

Stupid mistake with cookies :|

Quote Reply
Stupid mistake with cookies :|
Can anyone see a problem with this code?

Code:
my $cookie_pass = $IN->cookie (-name => 'pass',
-value => $pass
);

print $IN->header( -cookie => $cookie_pass );

my $cookie_user = $IN->cookie (-name => 'user',
-value => $id
);

print $IN->header( -cookie => $cookie_user );

For some reason, when calling them, only the 'user' one holds a value Unimpressed I've tracked down $pass, and that seems to be getting right upto where the cookie is set....so what am I doing wrong?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Stupid mistake with cookies :| In reply to
Well indeed because you are printing two headers.

Code:
my $cookie_pass = $IN->cookie (-name => 'pass', -value => $pass, -path => '/', -expires => '+1d' );
my $cookie_user = $IN->cookie (-name => 'user', -value => $id, -path => '/', -expires => '+1d' );

print $IN->header( -cookie => [$cookie_pass, $cookie_user] );

You want -path and -expires in there too.
Quote Reply
Re: [Paul] Stupid mistake with cookies :| In reply to
Eugh...knew it was something stupid! Think I better get some sleep after this last little bit...LOL

>>>You want -path and -expires in there too. <<<

Why? I only need the cookie available in memory of the browser, and accessable from the same script :)

Thanks Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Stupid mistake with cookies :| In reply to
Well ok for a session cookie you can remove the -expires but using path is still advisable as I've found that some browsers especially *honk* on macs, have a problem reading cookies without paths.
Quote Reply
Re: [Paul] Stupid mistake with cookies :| In reply to
Oh...ok. I'll get the path part added in then...thanks for the tip...

But first of all, I need some zzzzzzzzzzzzzzzzzzzzzzzz Crazy

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Stupid mistake with cookies :| In reply to
So is the problem solved........???

I add a path there but no luck..
Quote Reply
Re: [golden_water] Stupid mistake with cookies :| In reply to
Yeah, I sorted it out. Ended up using;

Code:
my $cookie_pass = $IN->cookie (-name => 'pass',
-value => $pass
);

my $cookie_user = $IN->cookie (-name => 'user',
-value => $id
);

print $IN->header( -cookie => [$cookie_user,$cookie_pass] );

Then to read it, I used;

Code:
$IN->cookie('user')

Hope that helps Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Stupid mistake with cookies :| In reply to
I see I made my speech on using -path for nothing :)
Quote Reply
Re: [Paul] Stupid mistake with cookies :| In reply to
Heheh...nah. Its included in the newest version...I just grabbed the code from one of the old versions of the plugin Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Stupid mistake with cookies :| In reply to
I am just doing some 'cookie' experiments myself. Could you post the version with -path in it? I don't know where the -path is meant to go.

Thanks in advance.

AndyB
Quote Reply
Re: [andybrock] Stupid mistake with cookies :| In reply to
Look at post 2.
Quote Reply
Re: [Paul] Stupid mistake with cookies :| In reply to
Doh! How dumb do I feel now Unsure

Thanks

Andy.