Gossamer Forum
Quote Reply
cookies
Hi,

Can we write and read cookies in just one request?

Thanks,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] cookies In reply to
Hi,

Simple answer, no =)

You have to write the cookie, and then when the page is re-loaded you can call the cookie. If you want to access it in the same page, you have to do something like;

$IN->cookie( -opts here -value=$IN->param('value') )


Then, you could use something like;

Code:
if ($IN->cookie('cookie_name')) {
print "Got: " . $IN->cookie('cookie_name');
} elsif ($IN->param('value')) {
print "Got: " . $IN->param('value');
} else {
print "Neither values exist...";
}

When working with logins, and "intermeditory" page normally sorts this. Example;

Login page --> Enters login details ---> Details are verified, and cookie set ---> "Please Wait" page shows, which just refreshes the page ---> The cookie should be set when the page is refreshed :)

Hope that helps.

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: [tandat] cookies In reply to
If you are writing the cookie then you already know the value so why would you need to retrieve it?

Btw - you can do it in a round about way if you are using GT::CGI by accessing the internal attributes of the cookie using the $IN object.

Last edited by:

Hargreaves: Nov 29, 2005, 6:55 AM
Quote Reply
Re: [Hargreaves] cookies In reply to
Thank you all.

The problem is I want to make sure the browser has stored that cookie or not so that I can print out the suitable content.

Javascript can help this?

Thanks,

Cheers,

Dat

Programming and creating plugins and templates
Blog