Best practice for login screen using database

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Best practice for login screen using database

    I have an c# as.net app that check if the user exist in a USERS table, that
    part is ok but now I need to pass the user ID no the next page beacuse I
    need to do some databse queries with that user ID, I'm passing the values as
    :
    Context.Items.Add("UserID",TempUserID);
    Context.Items.Add("VerifyString","OkPEV");
    Server.Transfer("timesheet.aspx", true);

    Now my problem is that in the timesheet.aspx page ths UserID come fine the
    first time, but if I do refeesh or add a record to my timesheet databse I
    loose the UseID.

    So is it any way to keep that variable on memmory while the session is open
    ?

    Thanks









    Carlos Guest

  2. Similar Questions and Discussions

    1. Login to admin system through login screen only
      Hi there, I have an issue relating to login to my asp.net application. Basically i have built the standard login page which compares against the...
    2. ASP (not Asp.Net) database best practice?
      Will the object variables of Connection, - Server.CreateObject("ADODB.Connection") Recordset - Server.CreateObject("ADODB.Recordset") and...
    3. session problem - login screen continually reloads after pressing the login button
      I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the...
    4. The login Screen
      Press CTRL -> ALT -> DEL at the welcome screen -- good luck! Please Send Reply only in newsgroup Tim
    5. best practice question regarding AspState database for sessions
      Quick question regarding best practices for using the AspState database for storing session variables in .NET web applications. I know I need to...
  3. #2

    Default Best practice for login screen using database

    Hi
    I see there is some problem with the logic you have
    chosen to adopt. If you pass the user ID through context
    variables, there is every possibility that a potential
    hacker could, do the same, just that he needs to know the
    context keys you have chosen to use.
    Instead, i would suggest you to use a different approach,
    where every page that needs the user to be signed-in
    should look up at a common function, which will return
    the user ID. For this to happen, you can design all your
    code-behind classes to inherit from a single base class,
    extending System.Web.UI.Page. And in the page_load events
    of all the pages, call the base class method, say
    base.CheckIfUserIsSignedIn();
    And in this base class method, write code in such a way
    that it will check if the user us signed in, based on
    some cookie value(i guess cookies are allowed) or you can
    use session variables. For the first time, when the user
    is shown a log-in form, s/he will be prompted to enter
    the credentials. Once validated, you can store the user-
    id token to a cookie or have it in session. The same can
    be used wherever required. Checking for signed in, in
    each page is to ensure, no one can by-pass the signed in
    form and directly land to some transaction form.
    The CheckIfUserSignedIn() method, should redirect the
    user to a sign-in form or access denied form, if it finds
    out that the user is not signed in.
    Hope this solves your problem too
    Let me know, if this has helped you in anyway.
    Ramjee
    >-----Original Message-----
    >I have an c# as.net app that check if the user exist in
    a USERS table, that
    >part is ok but now I need to pass the user ID no the
    next page beacuse I
    >need to do some databse queries with that user ID, I'm
    passing the values as
    >:
    >Context.Items.Add("UserID",TempUserID);
    >Context.Items.Add("VerifyString","OkPEV");
    >Server.Transfer("timesheet.aspx", true);
    >
    >Now my problem is that in the timesheet.aspx page ths
    UserID come fine the
    >first time, but if I do refeesh or add a record to my
    timesheet databse I
    >loose the UseID.
    >
    >So is it any way to keep that variable on memmory while
    the session is open
    >?
    >
    >Thanks
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >.
    >
    Ramjee Tanguturi Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139