cookies in windows form?

I'm an ASP.Net developer and web has "cookies" to save user's selection.

What's equal to Cookies in WinForm? In my login page, I have 2 radiobutons. I dont want the user to keep selecting them everytime they login. How can I save this user selection in a cookie?

I'm a VB.Net-er but for this, I'm using C# to learn C#.
LVL 7
CamilliaAsked:
Who is Participating?
 
REA_ANDREWConnect With a Mentor Commented:
Add a settings file and declare the scope as User not Application

Andrew
0
 
Jaime OlivaresSoftware ArchitectCommented:
You can save user preferences in Windows registry. To save, you can do something like:

                RegistryKey regKey = Application.CommonAppDataRegistry;
                regKey.SetValue("LoginName", loginname);

To retrieve:

                RegistryKey regKey = Application.CommonAppDataRegistry;
                loginname = regKey.GetValue("LoginName").ToString();
0
 
CamilliaAuthor Commented:
Thanks.I thought about the registery since our vendor app does that. But i thought there's a way around not playing around with a registery. Maybe save in a config file or something . But I'll try that.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
CamilliaAuthor Commented:
Then how to save/retreive in the settings File. I added it. Do see the "User" dropdown? User's name needs to be saved in that??
0
 
REA_ANDREWCommented:
OK so say you simply add a new settings file and it is callded Settings1.settings.  It is simply this:

Settings1.Default.Username = "Andy";

where Username is the name of the setting which I have declared as type string and scope User

Andrew

:-)
0
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
0
 
AutoeformsConnect With a Mentor Commented:
If you do not want to save info to the registry you can save it to a config file using serialization.  This is the strategy I use.  Plus I store the info in the directory on the server so it is available regardless of the machine they log into.

http://www.java2s.com/Code/VB/File-Directory/Serialize-to-XML.htm

good luck
Greg
0
 
CamilliaAuthor Commented:
let me read. I did this : Settings1 userSetting = new Settings1();

but seems like that's an overkill. Thanks Jaime, let me read the links.
0
 
REA_ANDREWCommented:
?

No it is static, do not instantiate anything:

Simply

Settings1.Default.Username

0
 
CamilliaAuthor Commented:
thanks. have another question but will close this. It works great.
0
All Courses

From novice to tech pro — start learning today.