Click here to Skip to main content
15,918,243 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
I have 2 question

1 - can I use cookies and session for C# program (i.e not ASP or web) its windows form project ?

2 - I need cookies in my program to remember the user
which I have to use ( cookies or session ) ?

thanks
Posted

Why would you want to use cookies and an explicit session in a desktop app? They are a mechanism for emulating a persistent application over a stateless protocol (HTTP), and they're just not necessary within a genuinely persistent application. Any state that you set (e.g. properties or fields on objects) will remain there until the end of the process, if the object stays in scope.

Assuming what you're really asking is 'how should I store state information?': I usually have a single repository for application data (either just on the main form or in a separate class with a static reference somewhere, depending on the complexity of the application), and create UI controls as views on some part of the data object (either using data binding or view-models). If you want to be able to load, save or remember state, you need to make the data object serialisable (I don't mean [Serializable] necessarily, but providing some mechanism of translating to/from byte streams).
 
Share this answer
 
Hi !
You can use the static variable retype cookie, seession in C# program windows.
If you want remember the user, you can use File libraries in C# to create file contains the users.
Goodluck !
 
Share this answer
 
Comments
maxpower12345 12-May-12 10:37am    
could you explain your first answer please , i'll be thankful :)
U have to use the cookies...

Beginner's Guide to ASP.NET Cookies[^]
I hope tis would be useful...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900