如何使用laravel Session :: get()读取Jquery $ .session.set(插件)(如果它甚至可能或以不同的方式执行此操作)
I have a problem i don't know how i would pass Session from Jquery to laravel so i can simply use Laravels Session:get(). Here is what i have, I have a div in which are radio buttons and they change on click (they are answers for questions) and on every click i use
$valueOfTheCheckedRadio = $('[name=answer]:checked').val();
$.session.set("val" + $click , $valueOfTheCheckedRadio); //$click is for the current number of question to get
And everything works fine i can get answers with $.session.get() in Jquery, but i would like to read that session with laravel. I know i might be doing this entirely wrong but any pointers or help would be appriciated on how i would do this.
我有一个问题我不知道如何将Session从Jquery传递到laravel所以我可以简单地使用Laravels 会议:get()方法。 这是我所拥有的,我有一个div是单选按钮,他们点击更改(他们是问题的答案)和每次点击我使用 p>
$ valueOfTheCheckedRadio = $( '[名=答案]:检查')VAL();
$ .session.set(“val”+ $ click,$ valueOfTheCheckedRadio); // $ click是当前要获得的问题数
code> pre>
一切正常我可以在Jquery中使用$ .session.get()获得答案,但是 我想用laravel阅读那个会话。 我知道我可能会这样做完全错了,但任何指针或帮助都会对我如何做到这一点有所帮助。 p>
div>
You can't there are no relation between jquery session and php session but you can use ajax to set a php session
function setSession(name,val)
{
$.session.set(name ,val); // jquery session
$.post(your_link,{'val':val,'name': name}, // php or Laravel session
function(data)
{
});
}
</script>
setSession("val" + $click,$('[name=answer]:checked').val()); // JS
in "your_link" php you can retrive name & val of your variable from ajx to set or update your php session
Client storage - it is sessionStorage
, different with php Storage. Use cookie instead.