ColdFusion 在页面更改时更改会话变量

发布于 2024-12-29 10:49:15 字数 221 浏览 4 评论 0原文

ColdFusion 有没有办法在页面更改后更改会话变量? - 特别是在页面更改为特定页面之后?

Goes to one page --> change session variable

Goes to a different page --> change session variable to something else

Is there a way in ColdFusion to change a session variable after a page change? - Especially after a page change to a specific page?

Goes to one page --> change session variable

Goes to a different page --> change session variable to something else

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬 2025-01-05 10:49:16

您可以在现有页面中添加代码吗?加载 importantpage.cfm 后,您可以在页面顶部运行它

这应该可以完成您正在寻找的内容。

您还可以将 标记添加到 application.cfm/cfc 文件中

Can you add code to the existing page? When importantpage.cfm is loaded you could run this at the top of the page

<cfset session.variable = 'important page loaded'>

That should accomplish what you are looking for.

You could also add <cfset> tags to your application.cfm/cfc file

楠木可依 2025-01-05 10:49:16

您可以在 application.cfm 或 application.cfc 中对其进行管理,然后这将延续到应用程序中的每个页面和子文件夹。您只需使用 CGI 变量作为页面名称执行 if 语句即可。

<cfscript>
if (findnocase("page1",cgi.script_name)) {
  session.myVar="Variable State 1";
} else if (findnocase("page2",cgi.script_name)) {
  session.myVar="Variable State 2";
} else {
  session.myVar="Variable State DEFAULT";
}
</cfscript>

You can manage this in application.cfm or application.cfc and then this will carry over to every page and subfolder in your application. You would just do an if statement using the CGI variable for the name of the page.

<cfscript>
if (findnocase("page1",cgi.script_name)) {
  session.myVar="Variable State 1";
} else if (findnocase("page2",cgi.script_name)) {
  session.myVar="Variable State 2";
} else {
  session.myVar="Variable State DEFAULT";
}
</cfscript>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文