Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. user should not login again if he is loggedin once during same browser [modified]

user should not login again if he is loggedin once during same browser [modified]

Scheduled Pinned Locked Moved ASP.NET
helpcomsales
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vikas shukla
    wrote on last edited by
    #1

    hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.

    modified on Saturday, March 27, 2010 5:02 AM

    A F M 3 Replies Last reply
    0
    • V vikas shukla

      hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.

      modified on Saturday, March 27, 2010 5:02 AM

      A Offline
      A Offline
      Arindam Tewary
      wrote on last edited by
      #2

      To remove "object reference not set to an instance of an object" error, you should check whether the session object is null before accessing Session["customer"] object.

      Thanks, Arindam D Tewary

      1 Reply Last reply
      0
      • V vikas shukla

        hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.

        modified on Saturday, March 27, 2010 5:02 AM

        F Offline
        F Offline
        Farraj
        wrote on last edited by
        #3

        try at the Page_load , first thing in ur page if (Session["customer"] == null) { Response.Redirect("URLOGINPAGE.aspx"); } this way, if the user still didnt logout, he will still have access to those secured pages without entering the login page again. till he logout

        1 Reply Last reply
        0
        • V vikas shukla

          hi sir please help me my problem is that if once a user is logged in then there should not be visible login page again after entring url. i mean suppose i have entered gmail.com in ie and login then if i again open gmail.com in new ie then login page is not there.while inbox page is open.i also want the same for my application.and on login page load i have done this. if (Session["customer"].ToString() == "Admin") { Response.Redirect("Admin/AdminHome.aspx"); } and i am giving my value to Session["customer"] on login click button from txtuserid.so that's why it gives me error.object reference not set to an instance of an object. please suggest me another suitable way to solve this issue.

          modified on Saturday, March 27, 2010 5:02 AM

          M Offline
          M Offline
          Member 4501940
          wrote on last edited by
          #4

          Session variables are not shared from window to window like that. If using forms authentication, this is what you are looking for.

              if (this.User.Identity.Name == "Admin")
              {
                Response.Redirect("Admin/AdminHome.aspx", false);
              }
          

          Normally you would do this the other way around. If the user tried to access AdminHome without being logged in, send them to the login and bounce them back from there if successful login.

          V 1 Reply Last reply
          0
          • M Member 4501940

            Session variables are not shared from window to window like that. If using forms authentication, this is what you are looking for.

                if (this.User.Identity.Name == "Admin")
                {
                  Response.Redirect("Admin/AdminHome.aspx", false);
                }
            

            Normally you would do this the other way around. If the user tried to access AdminHome without being logged in, send them to the login and bounce them back from there if successful login.

            V Offline
            V Offline
            vikas shukla
            wrote on last edited by
            #5

            thanks you very much sir for your support, i have an another issue.please suggest me.what should i do. when ever i am entering my url in browser ie and login page will display and i am doing successfull login.and now when i opened new browser and enter url it will show direct user home.it is absolutely right.but now sir when i am entering my url in mozilla or new browser.it should not show user home.it should show login page.but it shows user home. if you will try for gmail through ie.after login if you will open new gmail in mozilla it will not show inbox page while it will show login page. please suggest me how i can resolve this issue.

            M 1 Reply Last reply
            0
            • V vikas shukla

              thanks you very much sir for your support, i have an another issue.please suggest me.what should i do. when ever i am entering my url in browser ie and login page will display and i am doing successfull login.and now when i opened new browser and enter url it will show direct user home.it is absolutely right.but now sir when i am entering my url in mozilla or new browser.it should not show user home.it should show login page.but it shows user home. if you will try for gmail through ie.after login if you will open new gmail in mozilla it will not show inbox page while it will show login page. please suggest me how i can resolve this issue.

              M Offline
              M Offline
              Member 4501940
              wrote on last edited by
              #6

              Gmail - Your assumptions are not accurate. If you do not 'sign out' of gmail in mozilla, it will open the inbox page. Same with IE. IE and mozilla operate completely independant of each other. This behavior is usually acceptable. Assuming you are using the aspnet membership provider, you can test 'signout' functionality using FormsAuthentication.SignOut();. Anytime the signout is used, I also kill the session using Session.Abandon();. The membership provider behaves similar to gmail if that is the desired result.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups