简体   繁体   English

移动应用程序的Node js服务器端会话

[英]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-jwtexpress-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.

相关问题 在节点js中维护服务器端的会话 - Maintain sessions on server side in node js 如何使用Express为Android应用程序在node.js中实现服务器端会话? - How to implement server side sessions in node.js with express for an android app? 将cordova与Node.js集成以构建移动应用程序 - integrating cordova with node js to build mobile applications node.js可以用作在Web应用程序中运行任意服务器端Javascript的框架吗? - Can node.js be used as a framework for running arbitrary server-side Javascript in web applications? Node.js服务器重启会丢弃会话 - Node.js server restart drops the sessions 客户端到服务器端Node.js - Client Side to Server Side Node.js 如何使用节点js(服务器端)在移动应用程序中实现支付机制? - How to implement payment mechanism in mobile app using node js (server side)? 服务器端js上的同步(node.js) - synchronization on server side js (node.js) 什么是“PHP”的运行时环境,例如用于构建服务器端 Web 应用程序的“Javascript”的“Node.js”运行时环境? - What is and where is the runtime environment for 'PHP' like the 'Node.js' runtime environment for 'Javascript' to build server-side web applications? Node Js 是服务器还是服务器端脚本语言 - Is Node Js is server or server side scripting language
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM