From roberthpike at yahoo.com Mon Apr 12 08:01:41 2010 From: roberthpike at yahoo.com (Robert Pike) Date: Mon, 12 Apr 2010 08:01:41 -0700 (PDT) Subject: [kw-pm] CGI::Session Question Message-ID: <690808.25997.qm@web58703.mail.re1.yahoo.com> Has anyone experienced or (even better) know the reason why there is a problem with a certain CGI application I'm looking at? In the mentioned application, data is entered into one form and upon entering various information the form is submitted to another script (maintenance) for processing. After this script finishes it redirects back to the initial calling script. I'm using the CGI::Session module from activestate. I store the session ID inside of a cookie and then re-initialize the session if that cookie is present. At the end of the second script (maintenance) I store a hash within the session with the processed data (if I write to a file the hash shows the correct data). Upon being redirected back to the initial script (which displays a data that was processed as well) the session appears to either not exist or seems to be re-initialized (i.e. nothing in it). If I stop (i.e. exit) the maintenance script on first call before the script redirects to the other script and then (after it stops) I remove the exit and then refresh the page the session gets stored AND retrieved correctly (for instance a numeric value of 1 gets added for each run of the maintenance script - although by stopping at the end and then refreshing the page I would have thought 2 would have been added). I thought maybe it was some weird timing issue but if I store the value in the session and then recall it within the maintenance script, before the page gets redirected, the hash looks like it gets properly saved and retrieved (i.e. wrote to a file). Any ideas why this would be happening? Thanks, in advance, for any help. From roberthpike at yahoo.com Mon Apr 12 08:22:27 2010 From: roberthpike at yahoo.com (Robert Pike) Date: Mon, 12 Apr 2010 08:22:27 -0700 (PDT) Subject: [kw-pm] Earlier message regarding CGI::Session Message-ID: <76775.19226.qm@web58707.mail.re1.yahoo.com> Problem resolved. The script was missing a session->flush() line. I'm guessing that (although I've seen other scripts work fine without it) the problem was related to the redirect that was in the script. From roberthpike at yahoo.com Fri Apr 30 07:52:19 2010 From: roberthpike at yahoo.com (Robert Pike) Date: Fri, 30 Apr 2010 07:52:19 -0700 (PDT) Subject: [kw-pm] Redirecting using Perl Message-ID: <114963.43776.qm@web58703.mail.re1.yahoo.com> Hi All, I came across this when trying to redirect to another page in a CGI app I'm working on. I have a script (for simplicity, let's called it scriptA) that basically processes some data and then redirects to another perl script (again let's call this scriptB) that presents to the user a form to fill out. This "form" script's action property is set to recall itself. The thing is I'm trying to check (within scriptB) to see if the current script and the previous script are the same - when I make that recursive call back. First time the form gets submitted, the 2 are different still because the referer is still known to be scriptA and not scriptB. Is there a simple way to replace scriptA with scriptB first time when the form loads? I hope that makes sense. If so, any help would be appreciated. Thanks again. Rob From max at alleged.net Fri Apr 30 08:25:05 2010 From: max at alleged.net (Max) Date: Fri, 30 Apr 2010 11:25:05 -0400 Subject: [kw-pm] Redirecting using Perl In-Reply-To: <114963.43776.qm@web58703.mail.re1.yahoo.com> References: <114963.43776.qm@web58703.mail.re1.yahoo.com> Message-ID: <4BDAF651.50804@alleged.net> The browser is not even required to provide a Referer header, so you shouldn't rely on it. You should use a hidden item in the form to provide some known piece of data so you'll know where it came from. Cheers, Max Robert Pike wrote: > Hi All, > I came across this when trying to redirect to another page in a CGI app I'm working on. > I have a script (for simplicity, let's called it scriptA) that basically processes some data and then redirects to another perl script (again let's call this scriptB) that presents to the user a form to fill out. This "form" script's action property is set to recall itself. The thing is I'm trying to check (within scriptB) to see if the current script and the previous script are the same - when I make that recursive call back. First time the form gets submitted, the 2 are different still because the referer is still known to be scriptA and not scriptB. Is there a simple way to replace scriptA with scriptB first time when the form loads? > I hope that makes sense. If so, any help would be appreciated. Thanks again. > > Rob > > > _______________________________________________ > kw-pm mailing list > kw-pm at pm.org > http://mail.pm.org/mailman/listinfo/kw-pm >