Home  >  Article  >  Backend Development  >  怎么设计一个acess_token机制呢

怎么设计一个acess_token机制呢

WBOY
WBOYOriginal
2016-06-13 11:53:16933browse

如何设计一个acess_token机制呢?
为了验证用户的有效性
需要加入一个acess_token机制

小弟没想明白 这个东西要如何存储呢?

如果用户A第一次请求  分配给他一个acess_token = a(用a表示下)。然后把这个a以及生成时间存入数据库?

然后用户A接下来每次验证 都要从数据库中  查询下  a是否过期?过期的话 返回错误代码?是这个路子吗?求指点
------解决方案--------------------
这种 acess_token 一般是临时发放的(在登录成功后)
一般 api 用户量较大,发放的 acess_token 就包含有时间信息
这就不必劳烦数据库了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn