[Catalyst] Manipulating CGI cookie via Catalyst

sindharta_tanuwijaya at yahoo.co.jp sindharta_tanuwijaya at yahoo.co.jp
Wed Jun 4 02:33:36 BST 2008


Hey, it worked !!
I am not really sure, I think I've tried setting the domain before but it didn't work at that time, but I've never set the path before so perhaps that was the problem.

Anyway, yeah, just as you said, it's better to read the documentation more patiently next time before bumping myself to such problems.
Thanks a lot for the guides and advice, Mitch !

Sindharta

Mitch Jackson <perimus at gmail.com> wrote: On Mon, Jun 2, 2008 at 11:54 PM,   wrote:
> So does it mean that Javascript will regard different ports on the same
> domains as having the same domains while Catalyst apps will treat different
> ports as different domains ?

Cookies are not different depending on the programming language
(although some browsers will behave differently).  Cookies are just
pieces of text passed with HTTP headers.  Once you get how that works,
the feeling of 'cookies are this magic thing' goes away and you can
troubleshoot them easily.

In your javascript, you're setting your 'domain' field without a port
number.  In catalyst you are not specifying a domain field.  Have you
tried setting your domain field in catalyst the same way?

Learn to find what you're looking for by treasure hunting into the
documentation:

The documentation of the cookies method for catalyst tells you it
handles cookie objects with CGI::Cookie.
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7014/lib/Catalyst/Request.pm#$req-%3Ecookies

If you look at the documentation for CGI::Cookie, you will see you can
set: name, value, expires, domain, path, httponly and secure
http://search.cpan.org/search?query=CGI%3A%3ACookie&mode=all

$c->response->cookies->{testcookie} = {
    value => 'iamatestcookiemonster'
    expires => time()-86400,
    domain => 'sin.my.office.com',
    path => '/',
    httponly => 0,
    secure => 0,
};

Kind Regards,

/Mitchell K. Jackson

_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

 

 
---------------------------------
Power up the Internet with Yahoo! Toolbar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080604/88f46110/attachment.htm


More information about the Catalyst mailing list