记住登录用户的最佳方式 [英] Best way to remember a logged in user

查看:76
本文介绍了记住登录用户的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


使用cookie记住登录用户的最佳方法是什么?

您将用户名和密码存储在两个单独的cookie中吗?

密码应该是纯文本吗?哈希?不存在吗?


任何反馈都会有所帮助。谢谢!


-Josh

Hi All,

What is the best way to use a cookie to remember a logged in user? Would
you store the username and password in two separate cookies? Should the
password be plain text? Hashed? Not there at all?

Any feedback would be helpful. Thanks!

-Josh

推荐答案

Joshua Beall写道:
Joshua Beall wrote:
<大家好,

使用cookie记住登录用户的最佳方法是什么?将用户名和密码存储在两个单独的cookie中吗?
密码应该是纯文本吗?哈希?根本没有?

任何反馈都会有所帮助。谢谢!

-Josh

Hi All,

What is the best way to use a cookie to remember a logged in user? Would
you store the username and password in two separate cookies? Should the
password be plain text? Hashed? Not there at all?

Any feedback would be helpful. Thanks!

-Josh




通常情况下,我发现最好的方式是会话 - 这就是他们发明的东西
for。登录后,设置一个变量,如



Usually, I find the best way is with sessions - that''s what they were invented
for. Upon logging in, set a variable like


_SESSION [''username'']。如果他们点击

a注销按钮或尝试登录失败,请取消设置。


在您的脚本中,请务必检查是否
_SESSION[''username'']. If they click
a logout button or try to login unsuccessfully, unset it.

In your scripts, just be sure to check if


_SESSION [''username'']已设置。


或者,如果你想和你使用Apache,你可以使用htaccess / htpasswd。

然后,在您的脚本中,只需检查
_SESSION[''username''] is set.

Or, if you wanted to and you''re using Apache, you could use htaccess/htpasswd.
Then, in your scripts, just check


这篇关于记住登录用户的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆