Comments (7)
get~谢谢大佬w
from vue-example-login.
我说的token只是打个比方,简单的登录的话就是后端验证账号密码没问题后,就给客户端设置一个cookie就行了(这个cookie就是token)。客户端来判断是否存在这个cookie就ok,在登录后调用api都要带上这个token和user_id等,否则别人手动加了个cookie就可以免登录调到用户信息了。
token的生成是由已有的信息,比如用户的id,登录账号等经过加密处理(如md5( uid + 暗号 ))得到的,一般还要设置有效期扔到Redis这类缓存,所以不需要另建表。
from vue-example-login.
不太明白你说的意思哦。
from vue-example-login.
本来是想问如果我有多个页面,怎么能checkLogin(demo里是没cookie跳login有cookie跳info)。现在用的笨办法是每个页面判断没cookie跳login。不知道有没有更好的解决方法~
from vue-example-login.
另一个问题是,cookie里面设置的token是怎么获取的呢...之前用php的话session是后端自己处理完毕。
想到的流程是
- 前端验证登录
- api验证登录 信息正确的话生成一串token放在数据库中并返回给前端
但是这样的话每个页面验证都要读一次数据库 感觉不太对
from vue-example-login.
@fisherwise 一个域名下的所有页面的cookie是共享的,多个页面也没关系吧。
另外,像token这些是后端进行对session做了处理后,返回给客户端,客户端用cookie保存起来。用户打开页面时如果该cookie存在就免登陆不需要每次都到数据库,否则才去请求后端。
from vue-example-login.
就是说后端api自己维护一个表?
from vue-example-login.
Related Issues (12)
- 想问问有没有没有压缩的版本呢 HOT 1
- Error in created hook: "TypeError: this.getCookie is not a function" HOT 1
- App.vue 46行 HOT 1
- 路由问题
- 如果session过期,前端如何处理? HOT 1
- 移动端基本没法看啊,求移动端版本 HOT 1
- 路有变化检测状态? HOT 1
- 为什么不直接用store中的状态做登录判断呢? HOT 2
- 为什么有两个 position: relative; HOT 1
- 95th line a more }
- 其它子路由无法跳转 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-example-login.