Use PHP sessions with jquery

后端 未结 7 1554
我寻月下人不归
我寻月下人不归 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条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-26 10:15

    If you like to get access to PHP Sessions from javascript, you can write a simple wrapper.

    Somethign like this:

    
    

    Keep in mind that this is a possible security flaw, as everyone can get access to your PHP Session variables from outside (with a valid session id).

    Now you can simply use jQuery to ask the server for the current session data

提交回复
热议问题