|
session_is_registered
Find out whether a global variable is registered in a session
(PHP 4, PHP 5)
Return Values
session_is_registered() returns Notes
Note:
If
Caution:
If you are using Related Examples ( Source code ) » session_is_registered Examples ( Source code ) » Unregistering Variables Code Examples / Notes » session_is_registeredmiguel dot simoes
When using PHP 4.2.0 even on the same page where you registered the variable with: session_register("someVar"); if you try to see if the variable is set and do not assign it a value before, the function used in the previous comment will give the same output. This may show that the variable is declared and will not be set until some value is give assign to it. I think that this way will give the option to register all the variables used for sure on the process on the first page and using them as the time comes. somedude
Just to elaborate for those who may be having some problems. If you're using a newer version of PHP that comes with the register globals directive set to "off", you should heed the caution at the top of these notes. It's easier anyway. Instead of using session_register(...) , simply use somethig like: <? //must always start the session first session_start(); //in place of session register(..) use...like someone said above $_SESSION['VARNAME'] = $something // or "something"; /* then on the same page or subsequent pages where you want check for the session use something like.... and on another page where the session hasn't been started you have to call session_start(); first, if the session has already been started you don't need to call it again */ session_start(); //instead of session_is_registered(); if(isset($_SESSION['VARNAME'])) { print("What you want if the session var is set"); } else { print("What you want if the sessions variable is not set"); } ?> I hope this helps someone! If you want to learn more about $_SESSION and/or it's related "superglobals" try http://www.php.net/manual/en/printwn/language.variables.predefined.php good road! |
Change Languagesession_cache_expire session_cache_limiter session_commit session_decode session_destroy session_encode session_get_cookie_params session_id session_is_registered session_module_name session_name session_regenerate_id session_register session_save_path session_set_cookie_params session_set_save_handler session_start session_unregister session_unset session_write_close |