PHP - CSRF - How to make it works in all tabs?

前端 未结 2 1323
盖世英雄少女心
盖世英雄少女心 2020-12-01 01:56

I have read about how to prevent CSRF-attacks in the last days. I am going to update the token in every pageload, save the token in the session and make a check when submitt

2条回答
  •  渐次进展
    2020-12-01 02:30

    You could simply use a token which is persistent for the current session or even the user (e.g. a hash of the hash of the user's password) and cannot be determined by a third party (using a hash of the user's IP is bad for example).

    Then you don't have to store possibly tons of generated tokens and unless the session expires (which would probably require the user to login again anyway) the user can use as many tabs as he wants.

提交回复
热议问题