2

After moving my website from older to new version of PHP my login session show the following message undefined Function Session_Register but before upgrading this script work

Here is my login script

if($count=1)
{
    session_register('username');

    header("location:authorized.php");
}
Grant
  • 2,347
  • 2
  • 30
  • 40
brook
  • 103
  • 2
  • 14
  • See here: http://stackoverflow.com/questions/16082420/call-to-undefined-function-session-register – chrki Mar 07 '14 at 13:46
  • 1
    Always check the php documentation. You will see this: This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. (http://ro1.php.net/session_register) – keepwalking Mar 07 '14 at 13:47
  • put session_start(); at the head of your script – Mubo Mar 07 '14 at 13:50

5 Answers5

3

That function is deprecated. Use:

$_SESSION['username'] = 'value';
KristofMorva
  • 669
  • 1
  • 7
  • 13
1

session_register has been deprecated.

please use $_session['key'] and set your value in this

also must have session started before this:- session_start()

$_SESSION['username'] = 'anyvalue';

for get this session you need

$sss = $_SESSION['username'];
Rakesh Sharma
  • 13,570
  • 4
  • 35
  • 42
1
<?php
   session_start();
?>

Did you start session

Ferrakkem Bhuiyan
  • 2,577
  • 1
  • 18
  • 35
0

The function session_register was deprecated in version 5.3 and completely removed in version 5.4.

This means that you will have to change all instances of session_register from:

session_register('username');

to something like:

$_SESSION['username'] = $username;
Wayne Whitty
  • 19,088
  • 5
  • 43
  • 65
0

If facing session issue in Codeigniter, Then upgrade Codeigniter to latest version. Issue will resolved.

Anmol Mourya
  • 482
  • 5
  • 7