downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

session_module_name> <session_id
[edit] Last updated: Fri, 25 May 2012

view this page in

session_is_registered

(PHP 4, PHP 5 < 5.4.0)

session_is_registered変数がセッションに登録されているかどうかを調べる

説明

bool session_is_registered ( string $name )

グローバル変数がセッションに登録されているかどうかを調べます。

警告

この関数は PHP 5.3.0 で 非推奨となり、 PHP 5.4.0 で削除されました。

パラメータ

name

変数名。

返り値

session_is_registered() は、 name という名前のグローバル変数が現在のセッションに登録されている場合に TRUE、それ以外の場合に FALSE を返します。

注意

注意:

$_SESSION (または PHP 4.0.6 以前の場合は $HTTP_SESSION_VARS) が使用されている場合、ある変数が $_SESSION に登録されているかを確認するために isset() を使用してください。

警告

$_SESSION (もしくは $HTTP_SESSION_VARS) を使用している場合、 session_register(), session_is_registered(), session_unregister() を使用しないでください。



session_module_name> <session_id
[edit] Last updated: Fri, 25 May 2012
 
add a note add a note User Contributed Notes session_is_registered
amol_bhavsar1982 at hotmail dot com 22-Mar-2009 11:47
session_register() function is generating warnings. Therefore, instead of using:

<?php
$test
= 'Here';
session_register('test');
?>

It is better :

<?php
$_SESSION
['test'] = 'Here';
?>
somedude at wholikesphp dot com 31-Oct-2002 10:02
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!
miguel dot simoes at swirve dot com 13-Jun-2002 04:27
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.

 
show source | credits | sitemap | contact | advertising | mirror sites