Re: [Cgi-session-user] session data not being saved till flushed.
Brought to you by:
sherzodr
From: James.Q.L <shi...@ya...> - 2006-02-12 20:49:31
|
--- Cees Hek <ce...@gm...> wrote: > On 2/12/06, James.Q.L <shi...@ya...> wrote: > > I tried another example and it worked (logged is flushed).. > > % perl -MCGI::Session -e '{my $s=CGI::Session->new();$s->param("logged",1)}' > > > > I am posting my code here and hopefully someone can spot why it doesn't flush in the login > > subroutine. > > Nothing in the code you posted suggests any problems. So it must be > somewhere else in the code. Do you by chance pass the $self->session > object to your template? I believe that HTML::Template sometimes > hangs on to the parameters that you send to it, and hence the Session > object doesn't go out of scope (that is a wild guess btw) I do have $session object passed to HTML::Template as mentioned on CGI::Session tutorial. without editing that part, however, I tried my code again and session data is suddently all flushed without calling flush(). > > another question along with the code: in the login sub, if user passes the authentication then > > calls session method which will create new session and send cookie(since i have SEND_COOKIE > on), > > user will then be redirect to ./ . I am expecting a new cookie will be created when it is > > redirecting user to ./ but i don't see any cookie in the response header. therefor my script > > can't recognize the user as a logged in one. what's wrong in the code? > > Try it again without the 'domain' and 'path' options to the cookie. I > find that those two often keep cookies from being set correctly in the > browser (actually, to be more acurate, they are set correctly in the > browser, but the browser doesn't send them back on the next request). > You might also increase the expiry time while testing this. Also, > make sure that the cookie is actually being sent to the browser in the > first place (using something like the livehttpheaders plugin for > mozilla makes this really easy). I found out why the cookie doesn't sent during redirect. You see, i was using header_props for redirect which overrides the cookie header set in CPA::Session early on. that means header_props can't be used with CPA::Session and SEND_COOKIE is on. maybe this should be mentioned in CPA::Session doc? yes, I was using livehttpheader. now i find i need something to edit the cookie easily to test my script. the firefox extention "Add & Edit Cookies" looks promising, going to give it a go. > Cheers, > > Cees __________________________________________________________ Find your next car at http://autos.yahoo.ca |