[Cgi-session-user] FW: having big troubles saving params
Brought to you by:
sherzodr
From: Sherzod R. <she...@ha...> - 2007-04-26 20:57:26
|
-----Original Message----- From: Devin Austin [mailto:dev...@gm...] Sent: Friday, April 27, 2007 1:48 AM To: Sherzod Ruzmetov Subject: Re: [Cgi-session-user] having big troubles saving params here are the subs with session code in them (current code, not the plugin); sub cgiapp_prerun { my $self = shift; my $q = $self->query; my $session = CGI::Session->load("driver:file", $self->query, { Directory => "sessions/" } ) or CGI::Session->new("driver:file", $self->query, { Directory => "sessions/" } ) or die CGI::Session->errstr; $session->expire("+2m"); unless ( $session->param('is_logged_in') ) { $self->prerun_mode('main'); } } sub teardown { my $self = shift; my $q = $self->query; my $session = CGI::Session->load("driver:file", $self->query, { Directory => "sessions/" } ) or CGI::Session->new("driver:file", $self->query, { Directory => "sessions/" } ) or die CGI::Session->errstr; $session->flush; } sub do_login { my $self = shift; my $q = $self->query; my $username = $q->param('username'); my $passwd = $q->param('passwd'); my $session = CGI::Session->load("driver:file", $self->query, { Directory => "sessions/" } ) or CGI::Session->new("driver:file", $self->query, { Directory => "sessions/" } ) or die CGI::Session->errstr; # check for empty form values return $self->tt_process('error.tt', { title => 'Error!', error => 'Incorrect Username/Password Combination' }) if ( !$q->param('username') or !$q->param('passwd') ); ## retrieve user login info my $user_credentials = $schema->resultset('User')->search( { password => md5_hex("$username$passwd") } ); my $validated = $user_credentials->next; ## validate user if ( !$validated ) { return $self->tt_process('error.tt', { title => 'Error!', error => 'Incorrect Username/Password Combination' }); } else { ### SESSION STUFF ### my $session_cookie = $q->cookie( -name=> $session->name, -value=> $session->id, -expires=>'+2m', ); $session->param(-name=>'is_logged_in', -value=>'1'); ## user is logged in $session->expire('is_logged_in', '+2m'); ## user is "logged out" after 15 minutes $self->header_add(-cookie=>[$session_cookie]); $self->header_type('redirect'); $self->header_props(-url=>'?p=profile&user_id=' . $validated->user_id); return "Thanks for logging in, " . $session->param('username') . ". You'll be redirected shortly."; } } I apologize if this is lengthy, i'm just trying to incorporate everything that might affect the session On 4/26/07, Sherzod Ruzmetov <she...@ha...> wrote: Code sample would help. -----Original Message----- From: Devin Austin [mailto:dev...@gm...] Sent: Friday, April 27, 2007 1:33 AM To: Sherzod Ruzmetov Subject: Re: [Cgi-session-user] having big troubles saving params As soon as I started using CGI::Session in lieu of C::A::P::Session, the id wasn't being retained. However, when using the latter (the plugin), the id seemed to be retained. I'm passing the $self->query method On 4/26/07, Sherzod Ruzmetov <she...@ha...> wrote: Is the session Id being retained? Meaning, do you get different ID each time, or do you have the same session ID each and every time? -----Original Message----- From: cgi...@li... [mailto:cgi...@li...] On Behalf Of Devin Austin Sent: Friday, April 27, 2007 1:21 AM To: cgi...@li... Subject: [Cgi-session-user] having big troubles saving params Hey gang, any reason why i might be having troubles saving session params? the session is created (i've used both the mysql driver and flat file driver), but the params i'm trying to set (a "logged_in" param, and an expire time on that param using ->expire()) are NOT being set. I can't find errors, or anything. I've used CGI::Session, and CGI::Application::Plugin::Session (I'm using C::A btw.) Any ideas? -- timorperfectus.com <http://timorperfectus.com> - web design to frightening perfection. One last song Given to an Angel's Son As soon as you were gone As soon as you were gone -- timorperfectus.com - web design to frightening perfection. One last song Given to an Angel's Son As soon as you were gone As soon as you were gone -- timorperfectus.com - web design to frightening perfection. One last song Given to an Angel's Son As soon as you were gone As soon as you were gone |