Session Changes in php5.3 session_is_registered () isdeprecatedin

Source: Internet
Author: User
In php5.3, session_is_registered () has been abandoned. You need to pay attention to it during usage.

In php 5.3, session_is_registered () has been abandoned. You need to pay attention to it during usage.

In php5.3, the following code prompts:
Function session_is_registered () is deprecated in
Function session_register () is deprecated in

This means that these two functions are not in favor and are discarded.

The following is the code in the php official manual. The comments section shows that session_register () is not supported ()

The Code is as follows:


// Use of session_register () is deprecated does not approve of session_register ()
$ Barney = "A big purple dinw.ur .";
Session_register ("barney ");

// Use of $ _ SESSION is preferred, as of PHP 4.1.0 preferred $ _ SESSION
$ _ SESSION ["zim"] = "An invader from another planet .";

// The old way was to use $ HTTP_SESSION_VARS
$ HTTP_SESSION_VARS ["spongebob"] = "He's got square pants .";
?>

The following warning and prompt are displayed:
Warning
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
Warning: this function is not recommended in php5.3 and has been removed from php5.4.

Note:
If $ _ SESSION (or $ HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use isset () to check a variable is registered in $ _ SESSION.
Tip: If $ _ SESSION is used, check using the isset () function.

Caution
If you are using $ _ SESSION (or $ HTTP_SESSION_VARS), do not use session_register (), session_is_registered () and session_unregister ().

Php5.3 does not support session_register () this function has been deleted (solution)

Php is upgraded from 5.2.x to 5.3.2. Some previously used programs report errors.
The error message is:
Deprecated: Function session_register () is deprecated
Check that session_register 5.3 is not used. How can it be downgraded? Unhappy.
I searched and found a solution: Write a function.
// 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
Session_register ("abc ");
Change
$ _ SESSION ['abc'] = null;
You can.

,

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.