Use PHP sessions with jquery

后端 未结 7 1519
我寻月下人不归
我寻月下人不归 2021-01-26 10:02

Well, my question is simple:

I wish to use my PHP sessions in jQuery, in an if statement, however I do not know how I can do this on an easy way. Am I supposed to someho

7条回答
  •  萌比男神i
    2021-01-26 10:19

    You cannot import the $_SESSION, but you can store some of them (only those that you want) in the cookie and read it in javascript.

    For example: store the user-id in the cookie and you can read the value from the cookie in javascript.

    read cookie:

    function getCookie(c_name)
    {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i

提交回复
热议问题