session_is_registered

(PHP 4, PHP 5 < 5.4.0)

session_is_registeredFind out whether a global variable is registered in a session

Description

bool session_is_registered ( string $name )

Finds out whether a global variable is registered in a session.

Warning

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

Parameters

name

The variable name.

Return Values

session_is_registered() returns TRUE if there is a global variable with the name name registered in the current session, FALSE otherwise.

Notes

Note:

If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use isset() to check a variable is registered in $_SESSION.

Caution

If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().

Коментарии

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.
2002-06-13 07:27:04
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
session_register() function is generating warnings. Therefore, instead of using:

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

It is better :

<?php
$_SESSION
['test'] = 'Here';
?>
2009-03-23 01:47:56
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
For those who have an older application which uses the session_is_registered..and you want to use that in php5.4

You can just define the function if required

function session_is_registered($x)
{
    if (isset($_SESSION['$x']))
    return true;
    else 
    return false;
}

May be add the checks to ensure function is not already existing..
2013-04-07 19:54:15
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
The proper equivalent has nothing to do with isset().

Use array_key_exists() because session_is_registered returns true if the variable is in the session at all, even if it's falsy.
2013-12-05 20:03:50
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
Автор:
I can not get the following code to work as it is returning an error on the session_is_registered() and do I have to change anything else in the code 

Thank you

if(!session_is_registered('user_name')){

if (isset($_POST['username'])) {
$password1 = clean($_POST["password"]);
$username1 = clean($_POST["username"]);
$password2 = crypt($password1);

$result = @mysql_query ("select * from users where user_name = '".$username1."'");
$lim = @mysql_num_rows( $result );
//|| (strlen($username1) < 6) || (strlen($password1) < 6)
if( ($lim!=0)  ){
$row = @mysql_fetch_array($result);
$password=$row['user_password'];
if (crypt($password1, $password) == $password){
$sql = @mysql_query ("insert into logs (ip, cdate, status) values ('".$REMOTE_ADDR."','". date("Y-m-d H:i:s") ."', 'Login')");
session_register('user_id');
session_register('user_fullname');
session_register('user_name');

$_SESSION['user_name'] = $row['user_name'];
$_SESSION['user_fullname'] = $row['user_fullname'];
$_SESSION['user_id'] = $row['user_id'];
}//if crypt
else{
2014-02-06 11:56:54
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
A simple one-line function to emulate this in later versions of PHP:
function session_is_registered($x){return isset($_SESSION['$x']);}
2014-03-06 13:48:28
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
A simple one-line function to emulate this in later versions of PHP:
function session_is_registered($x){return isset($_SESSION['$x']);}
2014-03-06 13:48:30
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
Автор:
If your session variables may have NULL value,  use array_key_exists() instead of isset(). If not, use isset() because it performs better than array_key_exists().
2014-08-30 11:15:40
http://php5.kiev.ua/manual/ru/function.session-is-registered.html
There's an error in the comment posted by "someone at the dot inter dot net". Correct replacement for function session_is_registered() in PHP 5.4+ is 

function session_is_registered($x) {return isset($_SESSION[$x]);}

so just $x instead of '$x' - single quotation mark won't interpolate the variable $x and the function will always return false.
2015-02-05 00:08:49
http://php5.kiev.ua/manual/ru/function.session-is-registered.html

    Поддержать сайт на родительском проекте КГБ