You are here: Re: Why Does Registered Variable Become Null? « PHP Programming Language « IT news, forums, messages
Re: Why Does Registered Variable Become Null?

Posted by Michael Fesser on 08/09/07 19:37

..oO(kvnsmnsn@hotmail.com)

>In my code I also have a significant number of <session_unregister()>
>calls; I'm assuming I could just replace them with <unset()> calls; is
>that a correct assumption?

Correct.

>My code has thirteen variables that it calls <session_register()> on.
>Some of them are declared <global> and some are not. What does it
>mean to use the <global> keyword with a session variable as opposed to
>using a session variable without it, and how would I change that in my
>code to just use the <$_SESSION[ 'x']> format?

Just forget about that old deprecated session_register/unregister crap,
it's not needed anymore.

The $_SESSION array is superglobal, you can access it from everywhere.
If you want to put something into the session, write it to that array.
If you want to delete something, set it to NULL or use unset() or
whatever you like. Just use $_SESSION like a normal array - it's that
easy.

>Finally, when should I call <session_start()>? In particular, should
>I call it at the beginning of every function that accesses a
><$_SESSION[ 'x']> variable

No.

>or is it enough to call it at the begin-
>ning of each file that accesses such a variable?

Usually you call session_start() _once_ at the very beginning of a
script, so the session data will be loaded from disk and be made
available to your script.

Micha

 

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

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