You are here: Re: why a session-based program behaves different on different computers « PHP Programming Language « IT news, forums, messages
Re: why a session-based program behaves different on different computers

Posted by Jerry Stuckle on 04/20/07 13:01

davidkoree@gmail.com wrote:
> Thank you very much Steve.
>
> I will consider your recommendations seriously, that must be more
> stable than using cookie/session methods.
>
> Yesterday I checked my program and I found that there're two problems
> which made things bad.
>
> Let me show them:
>
> <?php
> require_once("F5S.php");
> session_start();
>
> print_r($_SESSION["f5s"]->_status); // -- bad one --
> /* This is bad one.
> * For example, if user has finished 3 steps, the $_SESSION["f5s"]-
>> _status should be:
> * { [step_1] => done, [step_2] => done, [step_3] => done }
> * But on some client computers the $_SESSION["f5s"]->_status may look
> like this:
> * { [step_1] => done, [step_3] => done }
> * or this:
> * { }
> * If we refresh the browser on or more times, the $_SESSION["f5s"]-
>> _status would be complete (or uncomplete).
> */
>
> if (isset($_SESSION["f5s"])) { // -- bad two --
> /* This IF is bad two, it doesn't return TRUE on some client
> computers.
> * But if we refresh the browser one or more times, the
> $_SESSION["f5s"] could be ok (or not ok).
> * Just like bad one.
> */
>
> $_SESSION["f5s"]->setFileName(__FILE__);
>
> if (count($_POST) > 0) {
> $_SESSION["f5s"]->collectData($_POST);
> $_SESSION["f5s"]->updateStatus();
> $_SESSION["f5s_data"] = $_SESSION["f5s"]->_data;
> $_SESSION["f5s_status"] = $_SESSION["f5s"]->_status;
> } elseif ($_SESSION["f5s"]->checkWorkflow()) {
> $_SESSION["f5s_data"] = $_SESSION["f5s"]->_data;
> $_SESSION["f5s_status"] = $_SESSION["f5s"]->_status;
> } else {
> $_SESSION["f5s"]->routeWorkflow();
> }
>
> } else {
>
> $_SESSION["f5s"] = new F5S();
> $_SESSION["f5s"]->setFileName(__FILE__);
> $_SESSION["f5s"]->routeWorkflow();
>
> }
> ?>
>
> The the server environment is PHP 5.1.4/Linux/Apache 2.0.
>
> I just searched bugs on php.net, and my issue seems like 'sessions are
> dropped randomly'.
> See more details please go to http://bugs.php.net/bug.php?id=37382
>
> And a bogus bug is inspiring me.
> See more details please go to http://bugs.php.net/bug.php?id=37444
>
>

Actually, David, going to a database won't work any better. You still
need to keep the key to the row in the session, and if you lose the
session you lose the database info.

If you force them to sign in, you could key the data to their user id;
then at least it would be saved when the session fails. But then
they'll have to log in.

The bogus bug you're referencing doesn't seem to apply because I don't
see anywhere you're doing $_SESSION=array(...) (unless it's someplace
else in the code).

One think I'm wondering - when you say "When user finish he/she can go
back to edit his/her inputs,..." do you mean by clicking on a review
button (or similar) on your page, or by clicking the "back" button on
their browser?

If the latter, the difference in behavior can be easily explained by
caching issues.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация