如何从另一个应用程序的 Catalyst::Plugin::Session::Store::File 读取服务器数据?
我在我的服务器上运行两个应用程序。第一个是 Catalyst 应用程序,配置为使用 Session
/
Session::State::Cookie< /代码>
/
会话::存储::文件< /code>
一套插件,用于在服务器端保存一些会话状态。
另一个应用程序是 Perl 语言,但不是 Catalyst。我希望 Catalyst 应用程序中的服务器端会话数据可供其他应用程序使用。
在第二个应用程序中,我可以加载客户端 cookie 并找到 Catalyst 应用程序的相关会话 ID,但之后我就陷入困境了。我不知道如何将会话 ID 映射到文件名。例如,我有一个会话 ID de079f151917d184219ef357f5298d0da478e015
,但该会话的数据只能在名为 fc1f6f651a2313c4081bcfef679061be35de40b7
的文件中找到。非 Catalyst 应用程序如何知道如何找到该文件? (我的后续问题是非 Catalyst 应用程序应该如何读取该文件,但当我到达它时我可以跨过那座桥)。
有没有更简单的方法可以使用不同的存储方案来做到这一点,例如 Session::Store::DBIC
或 Session::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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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 aCache::FileCache
with acache_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 beforetime()
.如果可能的话,我会将会话存储切换到数据库,然后就不需要搜索文件了。
希望有帮助。
If it is possible I would switch the session store to database, no need to search for files then.
Hope that helps.