bcrowell2 has asked for the wisdom of the Perl Monks concerning the following question:
I have a fairly large and fairly mature open-source CGI app https://github.com/bcrowell/spotter , which I recently converted to using CGI::Application::Plugin::Authentication for logins, since my old login code was buggy. This basically works great, except that it doesn't work in Google Chrome. Strangely enough, it does work in the version of Chromium that is packaged for Ubuntu, even though I would think it was essentially the same codebase as Chrome. The problem seems to be that although my login cookie is being set properly in all other browsers, in Chrome it doesn't get set. The following is what I got by cutting my app down to a minimal example of the difference in behavior:
Bug.cgi:
WebInterface.pm:#!/usr/bin/perl use strict; use WebInterface; WebInterface->new()->run();
This minimal example is obviously not functional, or even particularly logical (it only logs you out, not in), but it demonstrates the difference in behavior between browsers. If I run it in Chromium, a cookie named "login" shows up. If I run it in Chrome, no cookie shows up. (You can see this in Tools:Developer Tools:Resources:Cookies.) For anyone who wants to try running it, I have it installed here: http://www.lightandmatter.com/cgi-bin/Bug.cgi . You should see that in Firefox, IE, or Chromium, the cookie gets set, but in Chrome it doesn't.#!/usr/bin/perl use strict; package WebInterface; use base 'CGI::Application'; use CGI::Session; use CGI::Application::Plugin::Authentication; use CGI; WebInterface->authen->config( STORE => ['Cookie', NAME => 'login', SECRET => 'not really so secret', EXPIRY => '1d', ], ); sub setup { my $self = shift; $self->start_mode('my_run_mode'); $self->run_modes([qw/ my_run_mode /]); $self->mode_param('my_run_mode'); } sub my_run_mode { my $self = shift; $self->authen->logout(); CGI::Session->new(); return ''; } 1;
Can anyone suggest what's going on?
Normally I would expect that if a cookie was not getting set, the problem would be that either it wasn't being set with the correct domain, or the expiration date was not in the future. Here the expiration date is being set in the future, and I assume that CGI::Application::Plugin::Authentication bakes it with the correct domain (else it wouldn't work in any browser).
Any thoughts would be much appreciated.
-Ben
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Application::Plugin::Authentication not working on Google Chrome
by Anonymous Monk on Mar 12, 2013 at 06:18 UTC | |
|
Re: CGI::Application::Plugin::Authentication not working on Google Chrome
by scorpio17 (Canon) on Mar 12, 2013 at 15:24 UTC | |
by bcrowell2 (Friar) on Mar 12, 2013 at 15:36 UTC |