如何从另一个应用程序的 Catalyst::Plugin::Session::Store::File 读取服务器数据?

发布于 2024-12-28 20:02:08 字数 1315 浏览 3 评论 0原文

我在我的服务器上运行两个应用程序。第一个是 Catalyst 应用程序,配置为使用 Session/ Session::State::Cookie< /代码>/ 会话::存储::文件< /code>一套插件,用于在服务器端保存一些会话状态。

另一个应用程序是 Perl 语言,但不是 Catalyst。我希望 Catalyst 应用程序中的服务器端会话数据可供其他应用程序使用。

在第二个应用程序中,我可以加载客户端 cookie 并找到 Catalyst 应用程序的相关会话 ID,但之后我就陷入困境了。我不知道如何将会话 ID 映射到文件名。例如,我有一个会话 ID de079f151917d184219ef357f5298d0da478e015,但该会话的数据只能在名为 fc1f6f651a2313c4081bcfef679061be35de40b7 的文件中找到。非 Catalyst 应用程序如何知道如何找到该文件? (我的后续问题是非 Catalyst 应用程序应该如何读取该文件,但当我到达它时我可以跨过那座桥)。

有没有更简单的方法可以使用不同的存储方案来做到这一点,例如 Session::Store::DBICSession::Store::FastMmap< /代码>

I am running two applications on my server. The first is a Catalyst app, configured to use the Session / Session::State::Cookie / Session::Store::File suite of plugins to save some session state on the server side.

The other app is in Perl, but it's not Catalyst. I want the server-side session data from the Catalyst app to be available to the other app.

In the second app, I can load the client-side cookies and find the relevant session id for the Catalyst app, but after that I'm stuck. I don't know how to map the session id to a file name. For example, I have a session id de079f151917d184219ef357f5298d0da478e015, but the data for that session is only found in a file named fc1f6f651a2313c4081bcfef679061be35de40b7. How is the non-Catalyst app supposed to know how to find that file? (My follow up question would be how is the non-Catalyst app supposed to read that file, but I can cross that bridge when I get to it).

Is there an easier way to do this with a different storage scheme like Session::Store::DBIC or Session::Store::FastMmap?

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

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

发布评论

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

评论(2

暖阳 2025-01-04 20:02:08

Session::Store::File 使用 Cache::FileCache 。只需使用与您的应用放置会话数据的位置相对应的 cache_root 实例化 Cache::FileCache ,然后使用 $cache->get("session:$ sessid") 获取给定 $sessid 的会话数据,如果需要,请使用 $cache->get("expires:$sessid")< /code> 获取过期时间,这样如果会话在 time() 之前过期,您就可以忽略该会话。

Session::Store::File uses Cache::FileCache. Simply instantiate a Cache::FileCache with a cache_root corresponding to where your app puts its session data, then use $cache->get("session:$sessid") to get the session data for a given $sessid, and if you need it, use $cache->get("expires:$sessid") to get the expiry time so that you can ignore a session if its expiration is before time().

蒗幽 2025-01-04 20:02:08

如果可能的话,我会将会话存储切换到数据库,然后就不需要搜索文件了。

希望有帮助。

If it is possible I would switch the session store to database, no need to search for files then.

Hope that helps.

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