存储“记住我”本地信息c#(全新初学者)
几天前我开始用 C# 编程,所以我在这方面完全是新手。根据我使用其他语言的经验,我发现它有点“简单”。
我正在构建一个系统,用户可以登录我的应用程序,该应用程序正在运行。我想要一个“记住我”设置,信息存储在本地。最好的方法是什么?我只会保存用户名和密码哈希。
编辑:这是一个桌面应用程序。只需使用 HttpWebRequest 即可将登录信息发送到 php 脚本
I started programming in c# for a few days ago, so I am a total newbeginner at this. Based on my experience in other languages, I found it somewhat "simple".
I am building a system where users are logging in to my application, which is working. I want to have a "remember me"-setting where the information is stored locally. What is the best way to do this? I'll only save the username and the password-hash.
Edit: This is a desktop-application. The login-information is sent to a php-script simply using HttpWebRequest
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 ConfigurationManager 类来管理应用程序的设置。
您可以使用此功能将新的密钥添加到您的配置文件中:
然后保存您的用户名(例如)
一旦您的应用程序启动,您可以从
ConfigurationManager
读取您之前保存的信息You can use the ConfigurationManager Class to manage your application's settings.
you can use this function to add new Keys to your configuration file:
and then save up your username (for example)
Once your application starts up, you can read the information you saved earlier from your
ConfigurationManager
您可以在 C# 中创建应用程序设置
这就是您要做的做。
不要忘记加密它。
you can create Application Settings in C#
here's what you will do.
don't forget to encrypt it.
如果您使用的是 ASP .NET,则可以在用户登录时通过第二个参数设置身份验证 cookie。
第二个参数将 cookie 设置为您的请求,并设置“记住我”选项。
If you're using ASP .NET,you can set authentication cookie when you're logged in user by second parameter
Second parameter sets cookie to your request and makes "Remeber Me" option.
我从你的问题中了解到的是,php 文件是服务器,对于客户端,你使用的是 Windows 窗体。您正在执行某种 HTML 抓取并在 win 表单中显示结果 HTML。如果这就是您正在做的事情,
那么 AuthCookieName 是身份验证 cookie 的名称。唯一的缺点是当应用程序存在时,存储在字典中的所有 cookie 都会消失。如果选中“记住我”,解决方案可以是序列化 cookie 并将其存储在数据库中。
What I understand from your question is, php file is server and for client you are using windows form. Your are doing some kind of HTML scrapping and displaying the result HTML in your win-form. If this is the what you are doing then
Where AuthCookieName is the name of authentication cookie. The only downside is when the application exists all the cookie stored in the dictionary would be gone. The solution could be serializing the cookie and storing it in database, if remember me is checked.