Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 ASP.NET
Hi can Anybody give me an example for login page using sessions and how to implement sessions in login page and as well in the whole project
thanks in advance
Posted 18-Feb-11 5:33am
Edited 18-Feb-11 6:14am
Henry Minute223.9K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Go here and pick an appropriate tutorial:
 
http://www.asp.net/web-forms[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Advice and examples of using Session have been posted many, many times. Before asking a question here at least spend a few minutes doing some research.
 
Anyway, from code behind add your value as:
 
Session.Add("key", "value");
 
and get it back as:
 
object value = Session["key"];
 
That should get you going.
  Permalink  
Comments
Espen Harlinn at 20-Feb-11 9:19am
   
Good reply :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

protected void btnlogin_Click(objec sender,EventArgs e)
{
Userclass u=new Userclass();
u.Username=txtusername.text.trim();
u.Password=txtpassword.text.trim();
if(u.checkUser())
{
Session["youreSessionName"]=u.Username;
Response.redirect("./Home.aspx")
 
}
else
{
lblIsUser.text=" User DOes not Exist";
}
 
you will use session["yoursessioname"] as a user name in the project for other information about the logged user from database or somewhere
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Ok.
 
Have a login page designed. On submit button click event have something like:
{
  // Check for the authentication
  // if(authenticated)
  // {
  //    // Save the user profile/userid in a session.
  //    // Session["loggedInUserId"] = someId;
  // }
}
 
Whenever needed to verify or use the current loggedinId of the use, use Session["loggedInUserId"].ToString();
  Permalink  
Comments
Espen Harlinn at 20-Feb-11 9:18am
   
My 5 :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

protected void btnlogin_Click(objec sender,EventArgs e)
{
Userclass u=new Userclass();
u.Username=txtusername.text.trim();
u.Password=txtpassword.text.trim();
if(u.checkUser())
{
Session["youreSessionName"]=u.Username;
Response.redirect("./Home.aspx")
}
else
{
lblIsUser.text=" User DOes not Exist";
}
you will use session["yoursessioname"] as a user name in the project for other information about the logged user from database or somewhere
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Just write the following
For create session   :::   session["username"]="The value you want to send";
 
receive session  :::   if(session["username"]!=null){
                        your variable=session["username"].ToString();
                        }
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

crete session this way on login button click
Session["user"] = TextBox2.Text;
  Permalink  
Comments
Omprakash Kukana at 18-Sep-13 5:23am
   
this is the most comm on way of use of session and you can use this methd then y u downvoted my ans

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

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 18 Sep 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100