0

Coldfusion has a system created client variable called lastvisit.

Is there a way to get the value of that variable during the request that it is actually set (i.e. client.thisvisit)?

The idea would be that I can store the "ThisVisit" timestamp in session and then compare it to lastvisit when the next request is made. This would tell me if another request was made in the session.

The purpose is that we have a page that we use an ajax record lock on which refreshes the lock every minute. After sixty minutes the ajax lock code will automatically log the user out of the website (due to inactivity). The issue arises where the user is executing tasks in other windows/tabs (indication of activity).

Sense all requests update LastVisit, I would like to have the ajax lock code save the save a "thisvisit" value so that the next time it runs it can compare it to the LastVisit client variable.

4

1 回答 1

2

几个要求:

  • 设置为您的客户端变量使用数据库而不是注册表(相信我)。
  • 客户端变量必须启用“全局变量”
  • 您的 cfapplication 或 application.cfc 必须启用客户端管理。

如果您有这三件事,则可以选择如下查询:

<cfquery name="getLvisit" datasource="myClientVarsDB">
    SELECT lvist 
    FROM   cglobal
    WHERE  cfid = 
        <cfqueryparam type="CF_SQL_CHAR" value="#urltoken#"/>
</cfquery>

urltoken 可能是错误的......它可能需要 jsessionID 或 CFID,但我的记忆告诉我 cftoken。我必须使用客户端数据库搜索一个站点才能给你一个明确的答案。

所以这会给你 lvisit 变量的当前值。您可以将其存储在会话中,然后将其与后续查询中的表中的值进行比较,然后再次覆盖它(如果有意义的话)。

注意 - 这个值在每个请求上都会更新 - 所以你的查询得到的是当前值(它被更新之前)。我以前认为这是更新的,但根据汤姆的说法,它实际上是最后更新的。

于 2012-06-11T13:38:47.127 回答