Session_register and $_session

What is the difference between session_register and $_session?

Questions by krr_r25   answers by krr_r25

Showing Answers 1 - 6 of 6 Answers

bhavsarpr

  • Jun 9th, 2009
 

Following are differences between session_register and $_SESSION

1. session_register function returns boolean value and $_SESSION returns string value

2. session_register function does'nt work if register_global is disabled. $_SESSION works in both case whether register_global is disabled or enabled. So using $_SESSION for session variable manipulation is more appropriate.

 Please let me know if anyone has anything to add into this.

akaash19

  • Jun 11th, 2009
 

session_register() is a function .$_SESSION{} is a superglobal array.
session_register() is used to register a session variable and it works when register_globals is turned on.
$_SESSION works in both case.

Biswajit769

  • Jul 16th, 2009
 

session_register() is used for register one or more global variables with the current session. While $_SESSION[] array is used for storing one or more variables with in the current session array. session_register() depends upon register_global is enable or disable, If it disable it will not work.

session_register is  php function used to register variables with the current session.
But it will work only when register globals is turned on in php.ini configuration file.
$_SESSION is a superglobal array variable used for storing  variables that need to be used in current session.
Both methods are used for maintaing variables within current session.
But storing variables into $_SESSION array is more preferable  as it does not depend on register globals option in configuration file.

  Was this answer useful?  Yes

abc

  • Sep 12th, 2011
 

$_session for one or more variable
session_register for global variables

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions