You are here: Re: session data getting lost « PHP Programming Language « IT news, forums, messages
Re: session data getting lost

Posted by Erwin Moller on 11/24/05 11:19

jkmambo@gmail.com wrote:

> Session data is getting lost in PHP version 4.4.1 which used to work in
> version 4.3.3
>
> The code is similar to the one below
>
> Assume the file is called count.php which requires a parameter
> productid;
>
> session_start();
> if (!isset($_SESSION['countAccess'])) $_SESSION['countAccess'] = 0;
> else $_SESSION['countAccess']++;
>
> echo $_SESSION['countAccess'];
>
>

Why don't you use {} to mark your logical blocks?
This is PHP, not python. ;-)

Like:
session_start();
if (!isset($_SESSION['countAccess'])) {
$_SESSION['countAccess'] = 0;
} else {
$_SESSION['countAccess']++;
}

echo $_SESSION['countAccess'];


> if I call the script with a parameter for example
> count.php?productid=78
>
> when I press refresh button $_SESSION['countAccess'] does not get
> incremented but if I call it without the parameter,
> $_SESSION['countAccess'] gets incremented.


That ?productid=78 has nothing to do with the SESSION.
It will appear in $_GET, not $_SESSION.
So this is very surprising.
Do you have more code, without {}, that might interfere?
If yes: fix it, and if the problem persists, show us the code.

> I am also losing data if I call another script.
>
> Does anyone know what's going on here?
>
> Thank you

Regards,
Erwin Moller

 

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

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