You are here: Re: Ways to assign a value to a session variable. « PHP Programming Language « IT news, forums, messages
Re: Ways to assign a value to a session variable.

Posted by Jerry Stuckle on 01/14/08 01:53

Kurda Yon wrote:
> I am wandering which way to assign a value to a session variable
> exist. Which of the following examples will work.
>
> Example #1:
> session_start();
> session_register("ex");
> $ex = 2.0;
>
> Example #2:
> In first.php:
> session_start();
> session_register("ex");
> In second.php:
> $ex = 2.0;
>
> Example #3:
> In first.php:
> session_start();
> session_register("ex");
> Load second.php?ex=2.0
>
> Example #4:
> In first.php:
> session_start();
> session_register("ex");
> Go to the second.php via submission of the form on the first.php,
> which contains form-variable $ex.
>
> Example #4 seams not to work? Is it expectable?
>

session_register() has been deprecated. The correct way to do it is to
use the $_SESSION superglobal array, i.e.

session_start();
$_SESSION['ex'] = 2.0;

session_start();
$ex = $_SESSION['ex'];

BTW - there is no direct relationship between 'ex' as an index value,
and $ex as a variable.

--
==================
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

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