Php5.3 does not support session_register (). What should I do if this function is enabled?

Source: Internet
Author: User
Php5.3 does not support session_register (). What should I do if this function is enabled?

  1. // Fix for removed Session functions
  2. Function fix_session_register (){
  3. Function session_register (){
  4. $ Args = func_get_args ();
  5. Foreach ($ args as $ key ){
  6. $ _ SESSION [$ key] = $ GLOBALS [$ key];
  7. }
  8. }
  9. Function session_is_registered ($ key ){
  10. Return isset ($ _ SESSION [$ key]);
  11. }
  12. Function session_unregister ($ key ){
  13. Unset ($ _ SESSION [$ key]);
  14. }
  15. }
  16. If (! Function_exists ('session _ register ') fix_session_register ();
  17. ?>

Find another method and change session_register ("abc") to $ _ SESSION ['ABC'] = null.

Session changes in php5.3 (bbs.it-home.org script School) in php5.3 run the following code: Function session_is_registered () is deprecated inFunction session_register () is deprecated in, that is, these two functions are not in favor of use.

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

  1. // Use of session_register () is deprecated does not approve of session_register ()
  2. $ Barney = "A big purple dinw.ur .";
  3. Session_register ("barney ");
  4. // Use of $ _ SESSION is preferred, as of PHP 4.1.0 preferred $ _ SESSION
  5. $ _ SESSION ["zim"] = "An invader from another planet .";
  6. // The old way was to use $ HTTP_SESSION_VARS
  7. $ HTTP_SESSION_VARS ["spongebob"] = "He's got square pants .";
  8. ?>

The following warning and prompt is displayed: WarningThis 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. 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. If you are using $ _ SESSION (or $ HTTP_SESSION_VARS), do not use session_register (), session_is_registered () and session_unregister ().

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.