日期:2014-05-17 浏览次数:20544 次
$(document).ready(function () {
setInterval("Timer()", 62000);
})
function Timer() {
var strUrl = "Customer/TimeOver?time="+Math.random;
$.ajax({
type: "POST",
url: strUrl,
success: function (data) {
if (data.msg == "true") {
alert("登陆超时,请重新登陆");
window.parent.location.href = "/Account/LogOn";
}
}
});
}
public ActionResult TimeOver()
{
if (LoginOut(User.Identity.Name))
{
FormsAuthentication.SignOut();
return JsonGet(new { success = true, msg = "true" });
}
else
{
return JsonGet(new { success = false, msg = "false" });
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js读取cookie测试</title>
<link href="css/08nzfh-style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>
<body>
<div class="personality">
<script type="text/javascript">
//<![CDATA[
function setCookie(name,value)
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date(&nb