Undefined variable: _SESSION when sending variables via post through JavaScript trigger

前端 未结 8 511
执念已碎
执念已碎 2020-12-14 15:49

In my index.php file I call session_start() and set a couple of session variables. In a second PHP file I would like to access these session variables.

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 16:11

    Add the following code to the file browse.php:

    error_reporting( error_reporting() & ~E_NOTICE );
    if( ! ini_get('date.timezone') )
    {
        date_default_timezone_set('GMT');
    }
    if (version_compare(PHP_VERSION, '5.4.0', '<')) {
        if(session_id() == '') {session_start();}
    } else  {
       if (session_status() == PHP_SESSION_NONE) {session_start();}
    }   
    

    It will work fine.

提交回复
热议问题