简体   繁体   中英

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.

Within uploadify, you are able to assign script data which are key value pairs passed as parameters to the server. 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 .

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.

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. 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. You could do something simple by encoding your userid in your controller and passing this as script data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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