views:

209

answers:

3

I want to save user name and password in a cookie.mine is a win forms application.Please advice how can we do this.

Thanks

+1  A: 

In win Forms you should use registry,files,databases.... not cookies, cookies for web applications that usually be displayed in web browsers.

Wael Dalloul
+1  A: 

I would suggest using a password protected SQLite database (see System.Data.SQLite) and storing whatever you want there.

Also, do remember to hash your passwords!

Druid
A: 

This is not supposed to be an answers - more of a comment. Apologies if I posted it in the wrong way:

I expect the person asking the question may be aware that this is not the optimal way to store info in a winforms app. I would also like to know how to do this as a possible way of passing information from a website to a desktop app? For example you want the same app to do different things depending on information pass to the app from the website.

I've found that you can Retrieve Query String Information in a ClickOnce Application (http://msdn.microsoft.com/en-us/library/ms172242.aspx) which allows you to pass information from a site to an app. I want to know if cookies could also be used to do this.

I suspect it would be difficult and not practical in many situations to read info from a cookie in this way. One way I can think of doing this is putting a GUID in a cookie and also hardcoing that GUID into the app and running a find in files over the computer to find it. I realise that's a very ugly method but I would like to know what's possible.

I suppose another way might be to embeded a Webbrowser control in a winforms app and get the Webbrowser control to load a page containing JavaScript which reads that cookie. You would then need some way of passing that back to the .NET code though?

Pete