12
session_register("username"); // session checker for pages
$_SESSION['username']= $username; // storing username in session

I am doing a PHP login system but when I click login system I go this error

Fatal error: Call to undefined function session_register() in C:\xampp\htdocs\loginscript\auth_check.php on line 24

I am using PHP 5.3 how can I solve this problem?

Dharman
  • 30,962
  • 25
  • 85
  • 135
brianc
  • 211
  • 2
  • 3
  • 7

3 Answers3

27

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

Ref: http://www.php.net/manual/en/function.session-register.php

Dont use session_register(), session_is_registered() and session_unregister()

You can use $_SESSION[] instead of that

Like as mentioned below:

$_SESSION['username']= "Your value";
Krish R
  • 22,583
  • 7
  • 50
  • 59
11

Do not use session_register("myusername"); instead use

$_SESSION['username']= "username"; // storing username in session

session_register function has been deprecated since PHP5.3

Noor
  • 1,351
  • 8
  • 27
4

Use isset($_SESSION['username']) for check session Like as:

if(!isset($_SESSION['username'])){
   // go to login page code here.
    // in login page, store data into session, use following:
    $_SESSION['username']="username";
}
else{
   $username=$_SESSION['username'];// get previous session and go your project page
}

session_register() function has been deprecated since PHP5.3

Ahosan Karim Asik
  • 3,219
  • 1
  • 18
  • 27