Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: CGI::App session params losing values between redirects

by samtregar (Abbot)
on Feb 14, 2009 at 17:15 UTC ( #743841=note: print w/replies, xml ) Need Help??


in reply to CGI::App session params losing values between redirects

Can you post actual working code? Obviously what you posted is just a sketch of your code and it's hard to know what's going on. If not, here's how I would debug:

1. Is the cookie being sent back to the server by the client? You can check this with FireBug or by using a network analysis tool like WireShark.

2. Is the session setup code in your super class running? Maybe you have that session call in a method that's being overridden in the sub-classes and you're not calling $self->SUPER::whatever().

3. One way to test if it's #2 - duplicate the session config down into the two sub-classes. Does it start working?

-sam

  • Comment on Re: CGI::App session params losing values between redirects

Replies are listed 'Best First'.
Re^2: CGI::App session params losing values between redirects
by bradcathey (Prior) on Feb 14, 2009 at 18:16 UTC

    Thank you samtregar

    1. Is the cookie being sent back to the server by the client?

    Yes it is.

    2. Is the session setup code in your super class running?

    Here's the entire Super class. I don't believe there could be anything in another module that would be overwriting it (there's nothing that resets the session cookie--it's all done in Super):

    package Super; use warnings; use strict; use base 'CGI::Application'; use CGI::Application::Plugin::Redirect; use CGI::Application::Plugin::Session; use HTML::Template; sub cgiapp_init { my $self = shift; (my $http_host = $ENV{'HTTP_HOST'}) =~ s/(www.)([a-zA-Z0-9\-\.]+)/ +$2/; #--- Sessions & Cookies $self->session_config( COOKIE_PARAMS => { -name => 'MY_SESSID', -expires => '+8h', -path => '/', -domain => ".".$http_hos +t, }, SEND_COOKIE => 1, ); } 1;

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
      What's up with the -domain stuff? I think that could be your problem. Try removing it or replacing it with something static. Also, check that the clock on your webserver isn't more than 8h off (I've seen it happen!) since you're setting a pretty short expiration.

      Are you sure you don't have a cgiapp_init() defined in one of your sub-classes? Maybe add a warn() in the super class one and see that it actually prints when you run both sub-classes.

      -sam

        Thanks Sam.

        Two questions:

        1. What would something "static" look like for -domain or should I just kill the attribute?
        2. Dumb question of the day: so in any given instance, I can only have one cgiapp_init? I.e., one in my working module and one in the Super will overwrite each other? Makes perfect sense. Unfortunately, that's not what's happening here. But good to know. Duh!

        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://743841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2020-07-05 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?