[英]Node js server side sessions for mobile applications
Is there any way to keep server side sessions in node js for requests coming through mobile applictions, Or it is in a way compulsory to use other methods like jwt? 是否可以通过移动应用将请求中的服务器端会话保留在节点js中,还是必须使用诸如jwt之类的其他方法?
As we do in Web applications, ie Store the user information in the session on login and use the same information for later api calls. 就像我们在Web应用程序中所做的一样,即在登录时将用户信息存储在会话中,并在以后的api调用中使用相同的信息。
Yes, there is and the simplest solutions is to use JWT, you can implement jwt authentication in you node.js server with any approach you want like: passport-jwt , express-jwt ,... or even yourself with just jsonwebtoken npm package. 是的,最简单的解决方案是使用JWT,您可以使用任何想要的方法在node.js服务器中实现jwt身份验证: passport-jwt , express-jwt ,...甚至使用jsonwebtoken npm包自己。
then for keeping mobile application authenticated with server, store the jwt token in mobile local storage and when app is opened just check the storage for if the token is exist or not and when there is jut add the token to the header and practically your mobile app keep a seesion open with server. 然后,要使移动应用程序通过服务器进行身份验证,请将jwt令牌存储在移动本地存储中,当打开应用程序时,只需检查存储区中是否存在该令牌以及何时突出该令牌即可将令牌添加到标头中,实际上是将您的移动应用程序添加与服务器保持联系。
and for more information about jwt i ask a question about difference between session and cookie that might help you: Authentication: JWT usage vs session 以及有关jwt的更多信息,我问一个有关会话和cookie之间的区别的问题,这可能会对您有所帮助: 身份验证:JWT使用与会话
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.