如何重置会话变量 [英] How to reset session variables

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

问题描述

我正在开发一个应用。在CF10中。已经确定该应用。将通过在点网应用中创建的链接打开。
用户登录&通过点网应用程序退出以查看链接。当用户单击该链接时,他们可以访问CF应用程序。

I'm developing an app. in CF10. It's been decided that this app. will be opened through a link that is created in a dot net app. Users log in & out through the dot net application in order to see the link. When users click on that link they can access the CF application.

此链接传递了一个用户ID,我正在使用该用户ID创建session.userid
在application.cfc的onSessionStart中:

This link passes a user id, I'm using this user id to create session.userid in onSessionStart at application.cfc :

  <cfset session.userid = #Trim(URL.userid)#> 

问题是,当我注销并以其他用户身份重新登录时,上一次会话。用户名仍然存在。所以我有两个不同的session.userids
为了避免这种情况,我想我可以做以下事情:

The problem is, when I log out and log back in as a different user, my previous session.userid still exists. So I have two different session.userids In order to avoid this I thought I can do the following:

在application.cfc的onSessionStart中,我从sessionIvalidate函数:

in onSessionStart at application.cfc, I start with sessionIvalidate function:

   <cfset sessionInvalidate() />
   <cfset session.userid = #Trim(URL.userid)#>

我以为每次应用程序启动application.cfc ColdFsuion必须通过application.cfc运行,然后sessionInvalidate函数将清除现有的session.userid,然后创建一个新的session.userid,因此,如果我以与同一台计算机不同的用户身份登录和注销,则该应用程序仍将保留一个session.userid。
但不幸的是,这种方法不起作用!在没有创建新会话的情况下,我仍然可以使用较旧的会话!

I thought every time the application start application.cfc ColdFsuion has to run through application.cfc then sessionInvalidate function will clean out existing session.userid then a new one is created so if I log in and out as a different users from the same computer then the application still maintains one session.userid. But unfortunately this approach does not work! I still get the older session while the new session is not created!

如果我无法使用此逻辑来做到这一点,哪种方法最好呢?
我应该重新设置session.userid index.cfm吗?

What is the best approach to my situation if I can't do it using this logic. Should I re-set session.userid index.cfm instead?

推荐答案

使用注销顺序运行2单独的会话驱逐舰。这样我知道会话已被破坏。

With my log out sequence I run 2 separate session destroyers. This way I know the session is destroyed.

<cfset structClear( session ) />
<cfset sessionInvalidate()/>

我正在运行CF11,当我的客户从我的Web应用程序注销时,它的运行效果很好。

I am running CF11 and this works beautifully when my customers log out of my web application.

至于CFLOCK,取决于您使用的CF版本,将取决于您是否使用它。它在CF11中已贬值,当我进入CF11时,它破坏了我的应用程序。

As for the CFLOCK, depending on your version of CF will depend on if you use it. It's been depreciated in CF11 and when I went to CF11, having it broke my application.

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

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