Hi,


I'm new to asp.net and C# and I want to ask how to implement a session login using asp.net and C#. where i will connect it to my database.

Please advise.

Thanks.

Recommended Answers

All 2 Replies

OK, you'll have a database of course that contains the user name and passwords. You'll need to connect to that.
On your page you have the textboxes for user name and password and the login button.
The code for the button takes the user name and password and constructs an SQL statement that queries how many rows match with that user name/password combo (the correct answer is 1 or 0).
If 1 row is returned user can be logged in, set a session variable to true to indicate user is logged in. If rows returned equals 0, user was not found, session variable stays as false and the user gets to try again.
Thats it in a nutshell, with no code supplied. Have a go, do what you can and if you get stuck post your code up here.

login session in asp.net and C#
Session["SessionName"] = "yoursessionname";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.