简体   繁体   English

为什么在REST API中为app(android端)使用身份验证令牌而不是session_id

[英]why use authentication token instead of session_id for app(android side) in REST API

in normal php web application after login we use session_id that came from web browser to check if user loged in or not. 登录后的普通php web应用程序中 ,我们使用来自Web浏览器的session_id来检查用户是否插入。

But in REST API authentication I read some tutorials that say that php should send back authentication "token" for android app to save it and give it back to php server for every request. 但是在REST API身份验证中,我读了一些教程,说php应该为Android应用程序发回认证“令牌”以保存它并将其返回给php服务器以获取每个请求。

my question is why should I send back some authentication token instead of session_id? 我的问题是为什么我应该发回一些身份验证令牌而不是session_id? I can send back session_id by android app and do normal session stuff on php server side. 我可以通过Android应用程序发送回session_id并在php服务器端执行正常的会话。

ps. PS。 if my question is not clear tell then I explain more. 如果我的问题不清楚,那么我解释一下。

Well, REST API should be stateless, it's one of its defining characteristics. 好吧,REST API应该是无状态的,它是其定义特征之一。 You can use session id, but it wouldn't be REST anymore since you'll be operating a client state on server side. 您可以使用会话ID,但它不再是REST,因为您将在服务器端运行客户端状态。

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

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