top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between session_register and $_session?

+3 votes
177 views
What is the difference between session_register and $_session?
posted Sep 25, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

We can use either
session_register or $_SESSION for registering session variable in php.

Find below the difference between both of them.

session_register() is a function and $_SESSION is a superglobal array.

session_register() is used to register a session variable and it works only when register_globals is turned on. (Turning ON register_globals will create mesh-ups, but some applications (e.g OScommerce) requires turning ON of register_globals)
But $_SESSION works even when register_globals is turned off.

If session_start() was not called before session_register() is called, an implicit call to session_start() with no parameters will be made. But $_SESSION requires session_start() before use.

answer Oct 5, 2014 by Rajneesh
...