浏览器缓存对coldfusion登录的影响

时间:2013-02-20 09:18:29

标签: coldfusion browser-cache coldfusion-9

我有一个代码已经在过去两年的生产环境中没有任何问题,上周我们的托管公司倒了两天,当服务器重新上线时,我们的应用程序开始有一个特定的问题。

此问题是当您尝试登录时,它会将您带回登录页面,没有任何错误。 我提交了一张票,我被要求清除我的浏览器缓存。我清除了缓存,应用程序又开始工作了。

如果不清除浏览器缓存,是否没有其他方法可以解决此问题?

我尝试了几种方法,我用过

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

并且还使用了

<cflocation url="index.cfm" addtoken="yes">

请参阅Application.cfc的代码

<cfcomponent>

<cfset this.name = "some_app"> 
<cfset this.applicationTimeout = createTimeSpan(0,9,0,0)>
<cfset this.clientmanagement= "yes">
<cfset this.ClientStorage = "registry"><!--- this was formally cookie, i changed it to registry, but no change --->
<cfset this.loginstorage = "session" >
<cfset this.sessionmanagement = "yes">
<cfset this.sessiontimeout = createTimeSpan(0,4,0,0)>
<cfset this.setClientCookies = "yes">
<cfset this.setDomainCookies = "yes">
<cfset this.scriptProtect = "all">  
<cfset this.datasource = "some_dsn">

<cffunction name="onApplicationStart" output="false">

    <cfset application.scriptProtect = "all">

    <cfset application.sessions = 0>
    <cfset application.surportmail = "support@some_app.com"> 
    <cfset application.site.url = "http://some_app.com/"/>        
    <cfset application.com.Employee = CreateObject("component","com.user.Employee").init()/>
    <cfset application.com.Appraisal = CreateObject("component","com.Appraisal").init()/> 
    <cfset application.com.Security = CreateObject("component","com.system.Login").init()/>
    <cfset application.com.Log = CreateObject("component","com.adexfe.portal.system.Log").init()/> 
    <cfset application.com.Temp = CreateObject("component","com.adexfe.portal.Temp").init()/>
    <cfset application.com.Util.Security = CreateObject("component","com.adexfe.util.Security").init()/>   
    <cfset application.com.Security.url = application.site.url/>

</cffunction>

<cffunction name="onApplicationEnd" output="false">
    <cfargument name="applicationScope" required="true">

</cffunction>

<cffunction name="onRequestStart">
    <cfargument name="requestname" required=true/>

    <cflock type="exclusive" scope="session" timeout="10">
        <cfparam name="session.IsLogin" default="false" type="boolean" />
        <cfparam name="session.Userinfo" default=""  />
    </cflock>

    <cflock type="readonly" scope="session" timeout="40">
        <cfset request.IsLogin = session.IsLogin>
        <cfset request.UserInfo = session.UserInfo>
    </cflock>
    <!--- Check for login here --->
    <cfif Not request.IsLogin and ListLast(cgi.SCRIPT_NAME,'/') NEQ "login.cfm"  and ListLast(cgi.SCRIPT_NAME,'/') NEQ "forget.cfm">
        <cflocation url="login.cfm" addtoken="no">            
    </cfif> 

    <cfset application.com.Security.url = application.site.url/> 

    <cfset request.Security = application.com.Util.Security/>
    <cfparam name="url.bp" default="#request.Security.URLEncrypt('bp=home')#"/>     
    <cfset url.bpr = url.bp/>
    <cfif listfirst(url.bp,'=') eq 'h'>
        <cfset request.aurl = request.Security.URLDecrypt(listlast(url.bp,'='))/> 
    <cfelse>
        <cfset request.aurl.bp = url.bp/>
    </cfif> 

    <cfset request.aurl.bp = Replace(request.aurl.bp,'.','/','all')>


</cffunction> 

</cfcomponent>

Login.cfm代码:

<html>
<head>
<title>Login</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link href="Assets/css/reset.css" rel="stylesheet" type="text/css" />
<link href="Assets/css/login.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr><td width="50%" align="right"><br />      <img src="Assets/img/logo-b.jpg" width="445" height="164" /></td>
    <td><span class="label"> <img src="Assets/img/comp_logo.gif"  vspace="100" hspace="50" /></span></td></tr>
</table>

<cfform name="login">
<table width="300" border="0" align="center" >
    <tr><td nowrap class="label"> Email:</td>
    <td><cfinput class="in" name="username" message="Valid email address is required please" type="text" required="yes" /></td></tr>
    <tr><td height="41"  class="label">Password:</td>
    <td><cfinput  class="in" name="Password" style="color:red;"  required="yes" type="password"/></td></tr>
    <tr><td height="41">&nbsp;</td>
    <td><input type="submit" value="Login" class="sub"/><input name="Captcha" value="" type="hidden"></td></tr>
    <tr><td>&nbsp;</td>
    <td><a href="forget.cfm">Forget password?</a></td></tr>
</table>
</cfform>

<cfoutput>
<cfif structkeyexists(form,'Captcha')>
    <!---login with user info --->
    <cfset s = createobject("component","com.system.Security").init(false,false)/>
    <cfset l = createobject("component","com.system.Login").init()/>
    <cfset l.url = application.site.url/>
    <cfset l.SignIn(form,s)/>

    <cfif Not l.IsLogin>
        <div align="center" style="color:##F00; font-weight:bold;  text-align:center;">#l.errmsg#</div>
        <cfset application.com.Log.WriteLoginAttempt(form.username)/>
    <cfelse>
        <!--- set session --->
        <cflock type="exclusive" scope="session" timeout="30" throwontimeout="yes">
            <cfset session.IsLogin = true>
            <cfset session.userInfo = application.com.Employee.GetEmployee(l.userInfo.employeeid)/>
        </cflock>
        <cfset application.com.Log.WriteLoginSuccess(form.username,l.userInfo.employeeId)/>
        <cflocation url="index.cfm" addtoken="no">
    </cfif> 
</cfif>
</cfoutput>
</body>
</html>

谢谢

1 个答案:

答案 0 :(得分:0)

如果使用这些命令,可以在服务器上清除应用程序变量,如果要重置任何变量并重新启动应用程序,也可以使用structClear()。一般来说,一旦设置了应用程序变量,它们就会在内存中保持持久性,直到应用程序重新启动。

这些命令将重启应用程序。

<cfscript> applicationStop(); </cfscript> or <cfset applicationStop()>

清除变量后,您可以删除该行代码,并解决缓存问题。