dpmpa26468 2010-11-03 08:53
浏览 32
已采纳

关于使用PHP的网站上的会员登录; 怎么想?

I have a classifieds website, and I am about to create a members login section of the site.

I don't need anything advanced, just secure!

This is what I need in terms of functionality:

  • Website beeing able to recognize members so they don't have to login again (remember me)
  • Changing of their passwords and profiles
  • Logout page which removes the "remember me" so that website doesn't recognize next visit as "logged in"
  • Users beeing able to navigat while still logged in (kind of like the first functionality with "remember me" feature)

This is what I am thinking:

Create a MySql (I use MySql btw) table which contains Usernames, passwords etc.

Then create a "SESSION" in PHP and set a cookie to remember the user. This cookie will have something like this value in it:

    md5(IP.username.secret_word)

which I compare on top of each page so that the user is in fact the same user.

Next I need a logout page, which I am thinking of just deleting this cookie and destroying the session. Should be enough?

As for the still logged in feature, I will use the same method as the first remember me, which is to check for the cookie.

Is there anything I need to think about before doing this?

Sql injection, hacks, security flaws?

This isn't a bank or something which needs alot of security, but I would feel much better knowing it isn't easy to hack it.

One thing I am not sure about is the Session cookie. Is it any different from a regular cookie? Is it this cookie I should set when I use the "remember" feature?

Also, another last thing: If say 100 users are logged in at the same time, it means 100 sessions are running, will this slow down the performance of the website? (guessing yes).

Correct me, give me advice and information on how it is best done?

Thanks

  • 写回答

4条回答 默认 最新

  • dtqi87613 2010-11-03 08:58
    关注

    My recommendation would be to avoid attempting to re-invent this particular wheel. Good security is hard to do, but there are some excellent libraries available to do the job for you, e.g. Zend Auth.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真