简体   繁体   English

Play Framework:使用会话ID获取会话

[英]Play Framework : Get session using session id

I am using Uploadify to handle mutli-file uploads in my Play app and I am trying to work out the best way to associate a user with an upload. 我正在使用Uploadify来处理我的Play应用程序中的多文件上传,我正在尝试找出将用户与上传相关联的最佳方法。

Within uploadify, you are able to assign script data which are key value pairs passed as parameters to the server. 在uploadify中,您可以将作为参数传递的键值对的脚本数据分配给服务器。 So my idea, on the most basic level, is that I would like to pass the id of the users current session back to the upload method and then use the session id to get the session . 所以我的想法,在最基本的层面上,我想将用户当前sessionid传递回上传方法,然后使用session id来获取session

My question is: does anybody know how to get a session using the session id? 我的问题是:有人知道如何使用会话ID获取会话吗?

I understand that this is not the most secure way of doing this and I will be adding a few more complications along the way. 我知道这不是最安全的方法,我将在此过程中增加一些复杂性。 However, if someone knows, or can think of, a better away to achive what I am trying to do then I welcome their input. 但是,如果有人知道,或者可以想到,更好地实现我想要做的事情,那么我欢迎他们的意见。

First thing to understand is that the session is not a server side store. 首先要理解的是会话不是服务器端存储。 It is a cookie. 这是一个cookie。

Therefore, if Uploadify passes the cookie data up with the http headers, then you can access the session using the normal way you access a cookie from your controller. 因此,如果Uploadify使用http标头传递cookie数据,则可以使用从控制器访问cookie的常规方式访问会话。 This gets over your security concerns. 这可以解决您的安全问题。

If the cookie is not passed across, then you will have to find a neater way to pass information across. 如果cookie没有通过,那么你将不得不找到一种更简洁的方式来传递信息。 You could do something simple by encoding your userid in your controller and passing this as script data. 您可以通过在控制器中编写用户标识并将其作为脚本数据传递来做一些简单的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM