Why can't I access session variables from my AJAX-called PHP script?

前端 未结 7 1975
情话喂你
情话喂你 2021-01-11 11:03

I have one PHP script with a session variable, set like so:

$_SESSION[\'VAR1\'] = \"test\"

Now, I am using AJAX via a jQuery-initiated POST

相关标签:
7条回答
  • 2021-01-11 11:44

    An addendum to what Salman A wrote:

    If you set a session variable in an https:// file and try to access it with a http:// file you will not be able to...

    https://www.example.com/index.php - call session_start() and set session variable
    http://ww.example.com/index_tmp.php - unable to access session variable
    

    and vice versa...

    http://www.example.com/index.php - call session_start() and set session variable
    https://ww.example.com/index_tmp.php - unable to access session variable
    

    Rather:

    https://www.example.com/index.php - call session_start() and set session variable
    https://ww.example.com/index_tmp.php - Able to access session variable
    

    And:

    http://www.example.com/index.php - call session_start() and set session variable
    http://ww.example.com/index_tmp.php - Able to access session variable
    
    0 讨论(0)
提交回复
热议问题