[Catalyst] Manipulating CGI cookie via Catalyst

sindharta_tanuwijaya at yahoo.co.jp sindharta_tanuwijaya at yahoo.co.jp
Tue May 27 02:24:38 BST 2008


Hm, I just made a test application to test it. I included

Session
Session::Store::Memcached
Session::State::Cookie

in my app, added the following lines to app.yml

session:
  cookie_domain: '.sin.my.office.com'
  memcached_new_args:
    data:
      - localhost:11211
  verify_address: 0

and in Controller/Root.pm, default:

    $c->stash->{cookie_id}=$c->req->cookies->{id};
    $c->stash->{cookie_session}=$c->req->cookies->{session};

    delete @{ $c->session }{qw/__user/};
    delete @{ $c->session }{qw/id/};
    delete @{ $c->session }{qw/session/};
    
    $c->res->cookies
        ->{id} = {
            value => [],
            expires => 0,
        };
    $c->res->cookies
        ->{session} = {
            value => [],
            expires => 0,
        };
    $c->req->cookies
        ->{id} = {
            value => [],
            expires => 0,
        };
    $c->req->cookies
        ->{session} = {
            value => [],
            expires => 0,
        };
    $c->stash->{template}='index.tt2';

But the cookies just keep appearing, no matter how many times I refresh my browser.  I think there is something wrong, but I just couldn't figure out where.
Any ideas ? It couldn't be the memcached, could it ?

Sindharta

Gabriel Vieira <gabriel.vieira at gmail.com> wrote: The content changes? If yes, maybe you're updating the cookies after
the routine which should set it to a outdate value (the command you
just sended). If no, you are not accessing the right cookie.

On Mon, May 26, 2008 at 8:10 AM,   wrote:
> Hi,
>
> We are currently building an add-on for a site, which was built by using
> CGI, while the add-on is made by using Catalyst.
> Let's say that the sessions in the old site can be maintained by this simple
> PHP program.
>
> > setcookie("id", "sindharta", time() + 3600, "/", ".sin.my.office.com");
> setcookie("session", "blablablablablabla", time() + 3600, "/",
> ".sin.my.office.com");
> echo "cookies...\n";
> print_r($_COOKIE);
> echo "set!";
> ?>
>
> As you probably know, that's to set the login id, and you'll notice that I
> am not using Catalyst::Plugin::Authentication. Now, in the new add-on, I
> want to have a logout button so that the user can log out directly too, but
> I am having difficulty in programming that.
>
> I  have tried things such as:
> --
>     delete @{ $c->session }{qw/id/};
>     $c->res->cookies
>         ->{$cookie_name} = {
>             value => [],
>             expires => 0,
>         };
>
>     my $cookies = fetch CGI::Simple::Cookie;
>     $cookies->{session}->value([]);
>     $cookies->{id}->value([]);
> --
>
> But the cookie just won't disappear, it keeps coming back so that although I
> have pressed logout button, I am still considered as "login".
> Any ideas what went wrong here ?
>
> Sindharta
>
>
>
> ________________________________
> GANBARE! NIPPON! Win your ticket to Olympic Games 2008.
>
> _______________________________________________
> 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/
>
>



-- 
Gabriel Vieira

_______________________________________________
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/

 

 
---------------------------------
GANBARE! NIPPON! Win your ticket to Olympic Games 2008.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080527/f36c5b4b/attachment.htm


More information about the Catalyst mailing list