ASP经典和JavaScript检查会话状态 [英] ASP Classic and JavaScript check for session status

查看:138
本文介绍了ASP经典和JavaScript检查会话状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,试图找出如何去检查用户会话,看是否他们仍然登录或没有。

I am in need of some help with trying to figure out how to go about checking the users session and seeing if they are still logged in or not.

问题存在是因为我有pretty多负载万事成标签使用jQuery一个静态页面。因此,当用户浏览的页面,它真的永远不会离开这同一个页面,他们开始出来。提示在试图确定他们是否仍然登录或没有当他们更新点击他们的个人资料,或诸如此类的东西他们的信息我的问题。

The problem being is because i have a static page that pretty much loads everything into "tabs" using jquery. So when the user navigates the page, it really never leaves that same page they started out on. Hints my problem in trying to determine if they are still logged in or not when they click on update their information on their profile or whatnot.

推荐答案

创建,当用户导航页面服务器中某些arbitary通信。例如,当他们点击一个标签,尽管它不从服务器使用AJAX需要无论如何ping服务器。

Create some arbitary communication with the server when the user "navigates the page". For example when they click a "tab" despite it not needing from the server use AJAX to ping the server anyway.

当然,在现实中你将要检查会话是活反正毕竟用户可以在更新按钮,一个小时前,盯着实际上pressing它。

Of course in reality you will want to check the session is live anyway after all the user could stare at the "Update" button from an hour before actually pressing it.

您需要其他两个你会惹恼谁一直忙于使用应用程序,然后找到他们不知何故超时无论如何,这将违背其在其他网站上的用户体验。

You need both else you'll annoy users who have been busily using your app then find they're somehow timed-out anyway which will be contrary to their experiences on other sites.

在ASP你会存储在会话东西对象,以表明用户登录。这里有一个例子:我是登录页面: -

In ASP you would store something in the Session object to indicate that the user is logged on. Here is an example "Am I logged on" page:-

<%
Response.ContentType = "application/json"
If Session("LoggedOn") Then
   Response.Write "{loggedOn: true}"
Else
   Response.Write "{loggedOn: false}"
End If
%>

现在你可以使用这个页面作为平的目标。平之前更新。如果注销,我建议您发布的详细信息更新到服务器的任何地方,但不采取行动的最新情况。请求用户loggon在你平常的方式与重定向到一个网页,然后将这些行动的细节。

Now you can use this page as your ping target. Ping just before update. If logged off I would suggest that you post details for update to the server any where but not to action the update. Request user loggon in your usual way with a redirect to a page that will then action those details.

这篇关于ASP经典和JavaScript检查会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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