Deprecated: Function session_register () is deprecated Solution

Source: Internet
Author: User
Tags deprecated

After changing the Php environment today, we found that the error message "Deprecated: Function session_register () is deprecated" is displayed. I will introduce it to you.

Let's first look at the code

The Code is as follows: Copy code

<? Php
// Fix for removed Session functions
Function fix_session_register (){
Function session_register (){
$ Args = func_get_args ();
Foreach ($ args as $ key ){
$ _ SESSION [$ key] = $ GLOBALS [$ key];
}
}
Function session_is_registered ($ key ){
Return isset ($ _ SESSION [$ key]);
}
Function session_unregister ($ key ){
Unset ($ _ SESSION [$ key]);
}
}
If (! Function_exists ('session _ register ') fix_session_register ();
?>

I checked that there were not many issues. I found another method, directly
Set

The Code is as follows: Copy code

Session_register ("abc ");

Change

$ _ SESSION ['abc'] = null;

You can.

Summary

From the above process, we can see that this function has been deleted in PHP5.3. That is, this function is no longer available. You can simply use the following method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.