The change of Session in php5.3 session_is_registered () is deprecated in_php technique

Source: Internet
Author: User

Running the code in php5.3 will have the following hints:
Function session_is_registered () is deprecated in
Function session_register () is deprecated in

It means that these two functions are not in favor of, discarded.

The following is the code in the official PHP manual, and the comment section has indicated that it is not in favor of using Session_register ()

Copy Code code as follows:

<?php
Use of the Session_register () is deprecated not supported with Session_register ()
$barney = "A big purple Dinosaur";
Session_register ("Barney");

Use the $_session is preferred, as of PHP 4.1.0 First Selection $_session
$_session["Zim"] = "an invader from another planet.";

The old way is to use $HTTP _session_vars
$HTTP _session_vars["SpongeBob"] = "He's got square pants.";
?>

and have the following warning and hint:
Warning
This function has been deprecated as of PHP 5.3.0 and removed as of PHP 5.4.0.
Warning: This function is deprecated in php5.3 and has been removed in php5.4.

Note:
If $_session (or $HTTP _session_vars for PHP 4.0.6 or less) are used, use Isset () to check a variable is registe Red in $_session.
Tip: If $_session is used, use the isset () function to check.

Caution
If You are are using $_session (or $HTTP _session_vars), do not use Session_register (), session_is_registered () a nd session_unregister (). The

php5.3 does not support session_register () This function has been removed (workaround)

PHP upgraded from 5.2.x to 5.3.2. Out of the question. Some of the original programs can be used to correct the error.
The error is
Deprecated:function session_register () is deprecated
Check it out is 5.3 this session_register will not be used, down to the back? Upset.
A search was made, and one workaround was to write a function
<?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 ();
?>

checked for a few occurrences of this problem and found another way to directly
the
Session_register ("abc");
changed to
$_session[' abc ' = NULL;
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.