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

前端 未结 7 2052
情话喂你
情话喂你 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:37

    In jQuery or JavaScript, you can get the session value like this:

    var StepIndexval = '<%= Session["StepIndex"].ToString() %>';
    
    alert(StepIndexval);
    

提交回复
热议问题