http://www.perlmonks.org?node_id=999569


in reply to Re^3: Question on design for FastCGI
in thread Question on design for FastCGI

Thanks for the clear explanation.

FastCGI is harder than I had imagined at this point. I supposed I'm too accustomed to how non-persistent code works. Now, when I try to recode parts of the site to use FastCGI, I keep running into problems. For instance, with plain CGI + sessions, after a user logs out and tries to access a logged in page, my old plain CGI code works against it, so he's prevented from being logged in.

When I try to change that bit to use FastCGI, I discovered that by accessing a previously logged-in page after having logged out, a user can become logged in again - found out that it was probably due to the session being restored or something.

I've this nagging question and hope you can help enlighten me. Suppose I've some variables that hold different values depending on who's logged in e.g. no of points in a game. Am I right to say I should not set variables like this before the FastCGI loop, but to get their values for each response within the loop? Because if - what I think is happening - I set them before the loop, their values are retained due to the persistence and so different users may see the same values - or something to that effect. How do I prevent bugs like this from happening?

Replies are listed 'Best First'.
Re^5: Question on design for FastCGI
by Anonymous Monk on Oct 18, 2012 at 05:18 UTC

      Many thanks for your patience and enlightenment :)

      I had gone to the "CGI to mod_perl Porting, mod_perl Coding guidelines" before, which had given me some idea about what to expect. But until I actually encountered some of the issues caused by persistence, it was difficult to comprehend the ideas espoused. But I'm getting a better hang of it now than last week. At least now when something doesn't look right, I know where to look for the bug.

      Cheers and thanks again!