Harish Kumar
Harish Kumar

Reputation: 2105

Logout function

I am using a windows form application where a login form (login prompt) is used to authenticate an user and then open the application. Let us assume that I have a default admin username and password for logging in. When I click the close button of the application or choose File--> Exit, I want logout to be implemented so that the user has to again log in using his credentials when he starts the application for the next time. I want this to take place using C#

Any help on this guys?

Upvotes: 0

Views: 1085

Answers (5)

Madhana Kumar
Madhana Kumar

Reputation: 68

Normally,if you close the application its credientials will automatically go off. The application will start from stratch the next time you start.

In the scenario where the login session is carried over, do your logout tasks on FormClosing Event or FormClosed Event; when the form is closed, the session will not carry over.

Upvotes: 2

Damith
Damith

Reputation: 63065

you can add event handler for FormClosedEventHandler and log off the user on that event.

consider SystemEvents.SessionEnded event and Form.Closing Events

Upvotes: 0

Karel Frajták
Karel Frajták

Reputation: 4489

Your is user is authenticated only during the app start. If you will not implement some persistence mechanism to store the credentials or something like "cookie", then there's no need to deal with it - user will be prompted for credentials and authenticated on startup again.

Upvotes: 1

Sandeep Pathak
Sandeep Pathak

Reputation: 10747

Try logout on Form.Closing Event

Upvotes: 0

Tudor
Tudor

Reputation: 62439

You could implement logout actions inside the OnFormClosing() event handler of the form.

Upvotes: 1

Related Questions