如何在 Catalyst 中创建会话?

发布于 2024-08-10 17:45:24 字数 46 浏览 2 评论 0原文

尝试弄清楚如何在 Catalyst 中创建、存储和检索会话信息。有什么建议吗?

Trying to figure our how to create, store and retrieve session info in Catalyst. Any suggestions?

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

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

发布评论

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

评论(3

永不分离 2024-08-17 17:45:24

你只需要将相关的session插件添加到你的use Catalyst行即可,即:

use Catalyst qw/
                -Debug
                ...    
                Session
                Session::Store::FastMmap
                Session::State::Cookie
                /;

...然后你可以参考$c->session->{key} 从那里。有一些关于 cookie 年龄等的可配置项,但默认值是合理的。这应该可以帮助你开始。

(当然,如果您尚未安装这些与会话相关的模块,您可能需要从 CPAN 安装这些模块。)

You need only to add the relevant session plugins to your use Catalyst line, ie:

use Catalyst qw/
                -Debug
                ...    
                Session
                Session::Store::FastMmap
                Session::State::Cookie
                /;

... and then you can refer to $c->session->{key} from there. There are some configurables about cookie age and so on, but the defaults are sane. That should get you started.

(Of course, you may need to install those Session-related modules from CPAN, if they're not available to you already.)

墨落画卷 2024-08-17 17:45:24

只需使用 另一个 Catalyst 会话教程 更新此答案,该教程是 另一个 Catalyst 会话教程 ="http://search.cpan.org/dist/Catalyst-Plugin-Session" rel="nofollow">Catalyst::Plugin::Session 分发。看起来很容易理解,并且包含会话背后的基本概念

Just updating this answer with another Catalyst Session tutorial that is part of the Catalyst::Plugin::Session distribution. Seems easy to follow, and includes the basic concepts behind sessions

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文