[英]Web-based page session
I'd like to create a web app where the user is able to create a session, with the session being accessible even after leaving the page/browser. 我想创建一个Web应用程序,使用户能够创建会话,并且即使离开页面/浏览器也可以访问该会话。
An example would be http://lichess.org where the user goes to 'Create a game' and a page is created. 一个示例是http://lichess.org ,其中用户转到“创建游戏”并创建了一个页面。 That page then remains accessible even after the session is finished; 即使会话结束,该页面仍可访问; see: http://en.lichess.org/i8pV0vEv 参见: http : //en.lichess.org/i8pV0vEv
Essentially what I'd like to know is, what would be needed in order to create a similar effect. 从本质上讲,我想知道的是,创建类似效果所需的条件。 I've programmed tonnes over the years, just web environments are new to me! 这些年来,我已经为吨编程了,只是Web环境对我来说是新的! Scala seems like a contender, but in all honesty I have no clue. Scala似乎是一个竞争者,但老实说,我一点都不知道。 Perhaps javascript? 也许JavaScript?
Any advice would be appreciated, thanks. 任何建议,将不胜感激,谢谢。
Web programming is generally session-less and you need a cookie to simulate a session. Web编程通常不需要会话,因此您需要一个cookie来模拟会话。 You save this in your client's browser and in a database to be able to tie them together. 您可以将其保存在客户端的浏览器和数据库中,以便将它们绑定在一起。 Or you can use the browser-session which in the end is also a cookie, but does not scale very well as it's saved in the internal mechanisms of the web-server. 或者,您可以使用浏览器会话,该浏览器会话最终还是cookie,但扩展性不佳,因为它已保存在Web服务器的内部机制中。
There's nothing Scala specific here, but if you would like to give Scala a try, have a look at Play framework . 这里没有特定的Scala,但是如果您想尝试Scala,请看一下Play framework 。 It's pretty beginner friendly and already has built in support for everything you would need like Sessions , Cookies and Database access. 它非常适合初学者,并且已经内置了对您需要的所有内容的支持,例如会话 , Cookie和数据库访问。
If you want to store user session data permanently irrespective of whether user is on the website or not you may use browser storage facility of HTML 5. where you can store data on user's browser in form of key value pair and the data will be there permanently(based on type of browser storage you are using) and you can easily manipulate data using javascript. 如果要永久存储用户会话数据,而不管用户是否在网站上,都可以使用HTML 5的浏览器存储功能。在这里,您可以以键值对的形式在用户浏览器中存储数据,并且数据将永久存在于此。 (基于您使用的浏览器存储类型),您可以轻松地使用javascript处理数据。 There are mainly two types of browser storage. 浏览器存储主要有两种类型。
For your requirement my recommendation is to go for Local Storage 根据您的要求,我的建议是去本地存储
Advantages of Using Local Storage 使用本地存储的优势
Disadvantages of using local storage 使用本地存储的缺点
for further reference checkout w3schoold http://www.w3schools.com/html/html5_webstorage.asp 有关更多参考,请查看w3schoold http://www.w3schools.com/html/html5_webstorage.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.