4D Web 服务器和会话变量

发布于 2024-11-19 22:22:43 字数 443 浏览 1 评论 0原文

我正在开发一个使用专有 DBMS“第四维”制作的网站。我真的挣扎这个问题,因为我仍然是一个初学者,而且我只有在客户端服务器应用程序上使用 PHP 的经验。 4D 提供了一个 Web 服务器,可以处理 GET 和 POST 请求,并向客户端发送基本响应。

我的问题是: 似乎没有与 PHP 的 $_SESSION 等效的方法来存储持久变量,但我必须在访问者会话期间保留浏览历史记录,实现这一目标的好方法是什么?

我什至不知道如何在访问期间识别单个访客。 我真的很感激一些帮助。 问候, caffein

TL;DR 用任何语言模拟 PHP 会话的最佳方法是什么?

I'm working on a Website made with the proprietary DBMS "4th Dimension". I'm really struggling with this, as I'm still a beginner, and I only have experience with PHP on client-server apps. 4D provides a Web Server that can handle GET and POST requests, and send basic responses to the client.

My question is:
There seems to be no equivalent of PHP's $_SESSION to store persistant variables, but I have to keep a browsing history during the visitor's session, what's the good way to achieve that?

I don't even have a clue on how I could identify a single visitor during his visit.
I would really appreciate some help.
Regards,
caffein

TL;DR What's the best way to mimic PHP's session in any language?

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

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

发布评论

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

评论(2

幸福还没到 2024-11-26 22:22:43

从 4D 知识库查看此峰会会议:Web 会话管理:跟踪您的 Web 用户 。它包含注释和示例 .4DB。

我还建议在 KB 和 iNUG 邮件列表上进行更彻底的搜索(您必须是手动批准后才能发帖,但可以浏览档案)。

尽管我很喜欢,但 iNUG 确实是接触 4D 开发人员的最佳场所。

Check out this Summit session from the 4D knowledge base: Web Session Management: Tracking Your Web Users. It is complete with notes and a sample .4DB.

I'd also recommend a more thorough search on the KB and the iNUG mailing list (you have to be manually approved before you can post, but you can browse archives).

As much as I like SO the iNUG really is the best place to get in touch with 4D devs.

随遇而安 2024-11-26 22:22:43

4d v14 具有本机会话管理;要激活它,只需在数据库设置中设置“自动会话管理”选项即可(cfr 4d Web 会话管理 ) 或使用命令 WEB SET OPTION(Web Keep session; 真的)。

会话从 4d 开始使用 cookie 进行维护;每个过程变量和记录选择均得到维护。

在“On Web Connection”数据库方法的代码中,您可以编写:

C_TEXT(www_SessionID)
If(www_SessionID=**WEB Get Current Session ID**)
    // All variables and selection already exist
    ...
Else
    // Compiler_Web has just been executed.
    // This is a new session, no variable or selection exists
    // Keep track of the session that 4D just created
    www_SessionID:=**WEB Get Current Session ID**

    // Initialization of session
    // Set up selections
    // find connected user
    QUERY([User];[User]Login=www_Login)
    QUERY([prefs];[prefs]Login=www_Login)

    // Setup variables
    // Get prefs for this user
    www_UserName:=[User]Name
    www_UserMail:=[User]mail
End if

The 4d v14 has native session management; to active it it is enough to set on the "Automatic Session Management" option in Database Settings ( cfr 4d Web Session Management ) or use the command WEB SET OPTION(Web Keep session; true).

The session is maintained from 4d using cookies; every process variable and records selection is maintained.

In the code of "On Web Connection" Database method you can write:

C_TEXT(www_SessionID)
If(www_SessionID=**WEB Get Current Session ID**)
    // All variables and selection already exist
    ...
Else
    // Compiler_Web has just been executed.
    // This is a new session, no variable or selection exists
    // Keep track of the session that 4D just created
    www_SessionID:=**WEB Get Current Session ID**

    // Initialization of session
    // Set up selections
    // find connected user
    QUERY([User];[User]Login=www_Login)
    QUERY([prefs];[prefs]Login=www_Login)

    // Setup variables
    // Get prefs for this user
    www_UserName:=[User]Name
    www_UserMail:=[User]mail
End if
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文