NYCPHP Meetup

NYPHP.org

[nycphp-talk] problem: session variables disappear after redirection

Paul M Jones pmjones88 at gmail.com
Wed Jun 13 22:51:24 EDT 2007


On Jun 13, 2007, at 6:29 PM, Michael Southwell wrote:

> I have a form which submits to a processor script. The processor
> writes the post variables into the session and checks for correctness.
> If there is a problem, it redirects to the form which is preloaded
> from the session, and we start over again. If there is no problem, the
> processor redirects to a thanks page which pulls the submitted
> information out of the session and sends it via email and says
> "thanks" to the submitter.
>
> This works perfectly for everybody except two out of about 400 people.
> Unfortunately one of those two is an officer of the organization.
>
> I have determined that, even for these two people, the processor does
> indeed receive the post variables and does indeed write them into the
> session. But (for those two people, and only for them) when we get to
> the thanks page, the session information is somehow lost in the course
> of the redirection, and so the email is sent with blank information.
>
> The two people for whom this is happening are both on Macs, and both
> experience the problem with both Safari and Firefox. Other Mac users
> with either browser have no problem.
>
> Can anyone imagine or suggest what might be happening here?

The only suggestion I can think of is to explicitly call  
session_commit() or session_write_close() just before the redirect.

   <http://us.php.net/manual/en/function.session-commit.php>
   <http://us.php.net/manual/en/function.session-write-close.php>

This will force the session values to be stored before the redirect.   
(Other comments on the session_write_close() page may be of use to  
you here.)


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.   <http://solarphp.com>

Savant: The simple, elegant, and powerful solution for
templates in PHP.   <http://phpsavant.com>





More information about the talk mailing list