session_register() function is generating warnings. Therefore, instead of using:
<?php
$test = 'Here';
session_register('test');
?>
It is better :
<?php
$_SESSION['test'] = 'Here';
?>
session_is_registered
(PHP 4, PHP 5)
session_is_registered — 전역 변수가 세션에 등록되었는지 확인
설명
bool session_is_registered
( string $name
)
전역 변수가 세션에 등록되었는지 확인합니다.
Warning
이 함수는 PHP 5.3.0부터 배제되었고 PHP 6.0.0부터 제거됩니다. 이 기능에 의존하지 않기를 권합니다.
인수
- name
-
변수명.
반환값
session_is_registered()는 전역 변수명이 name 인 변수가 현재 세션에 등록되어 있으면 TRUE를, 아니면 FALSE를 반환합니다.
주의
Note: $_SESSION(또는 PHP 4.0.6까지 $HTTP_SESSION_VARS)을 사용하면, $_SESSION에 변수가 등록되었는지 확인할 때 isset()을 사용하십시오.
Caution
$_SESSION(또는 $HTTP_SESSION_VARS)를 사용한다면, session_register(), session_is_registered(), session_unregister()를 사용하지 마십시오.
session_is_registered
amol_bhavsar1982 at hotmail dot com
23-Mar-2009 07:47
23-Mar-2009 07:47
somedude at wholikesphp dot com
31-Oct-2002 06:02
31-Oct-2002 06: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 11:27
13-Jun-2002 11: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.
