在javascript函数中设置会话变量 [英] Setting session variable in javascript function

查看:75
本文介绍了在javascript函数中设置会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我通过Facebook登录我的网站后收到用户的姓名和电子邮件ID ..

我想使用javascript在登录表单本身的会话中添加这些变量;

我试过以下

Hi,

I am getting name and email id of a user after he logs in via facebook to my website..
I want to add those variables in session on login form itself using javascript;
I tried following

FB.api('/me', function (me)
 {                       
   if (me.name)
   {
     document.getElementById('auth-displayname').innerHTML = me.name;
     <%Session["fbName"] = me.name; %>
   }
 }



它给出了像我这样的错误(在这一行:< ;%Session [fbName] = me.name;%>)在当前上下文等中不存在。



我该怎么做


it gives error like me (in this line: <%Session["fbName"] = me.name; %>) does not exist in the current context etc.

How can I do this

推荐答案

会话是服务器端技术。客户端/浏览器对ASP.NET会话一无所知。



我假设您使用JavaScript代码在客户端获取详细信息。您将需要d回发页面,然后将详细信息保存在服务器端的Session变量中。
Session is a server side technology. Client/Browser doesn't know anything about ASP.NET Session.

I am assuming you get the details on client side using JavaScript code. You will need to post back the page and then save the details in the Session variable on the server side.


我假设auth-displayname是服务器端隐藏字段。尝试更换

I am assuming "auth-displayname" is a server side hidden field. Try replacing
<%Session["fbName"] = me.name; %>



with


with

<%Session["fbName"] = auth-displayname.Value; %>


这篇关于在javascript函数中设置会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆