How to avoid that a user removes his session

别等时光非礼了梦想. 提交于 2019-12-06 13:12:59

as users are not stored and maintained its very difficult and can't be made 100% sure.

how i try to achieve this most closely is using request ip address and csrf token. you can get ip address from request and csrf_token() from anywhere inside your laravel application.

here is an example of how i am going to implement

create a table named votes having following fields

  • votable_type
  • votable_id
  • ip_address
  • csrf_token

i would check whether a client does not have an existing record for same votable type and id. client is a the csrf_token. ip is for guaranteeing whether the requests are legit.

votable type and id is the polymorphic relationship between either may be comments, posts etc.

note

without persisting user identification in anyway some users might not be either vote or some might vote twice. it can't be done perfectly.

  • some users might vote from different user agents multiple times.
  • some users might spoof ip. clear cookies
  • different users might be using same system to login.
  • some users might be using different connections or system logins.

so either we take any information it wouldn't be 100% accurate.

manniL

My solution was combination of implementing evercookie to assign a "Identification Cookie" per user, detecting privacy browsing and restrict access when having Incognito mode or private browsing enabled, and finally restrict several actions (voting in my case) when not having the evercookie.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!