简体   繁体   中英

PHP session won't work after updating PHP version

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");
}

That function is deprecated. Use:

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

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'];
<?php
   session_start();
?>

Did you start session

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;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM