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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. using sessions in asp.net

using sessions in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
9 Posts 3 Posters 9 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.
  • S Offline
    S Offline
    Suave_Shiva
    wrote on last edited by
    #1

    The session should expire after 10mins & should redirect to login page. Also when user logged, click back button from browser & then clicking forward button,the session should expire & made him to Relogin again,please send code to me as soon as possible.Thanks in advance to whom so ever sending me the code...................... Shiva

    W E 2 Replies Last reply
    0
    • S Suave_Shiva

      The session should expire after 10mins & should redirect to login page. Also when user logged, click back button from browser & then clicking forward button,the session should expire & made him to Relogin again,please send code to me as soon as possible.Thanks in advance to whom so ever sending me the code...................... Shiva

      W Offline
      W Offline
      wEb GuRu
      wrote on last edited by
      #2

      In Web.config add... <sessionState timeout="10" />

      Lets work it Out.........!

      S 1 Reply Last reply
      0
      • S Suave_Shiva

        The session should expire after 10mins & should redirect to login page. Also when user logged, click back button from browser & then clicking forward button,the session should expire & made him to Relogin again,please send code to me as soon as possible.Thanks in advance to whom so ever sending me the code...................... Shiva

        E Offline
        E Offline
        enjoycrack
        wrote on last edited by
        #3

        As the previous poster => session expire after 10mins

        Suave_Shiva wrote:

        The session should expire after 10mins & should redirect to login page

        you should handle the session time out event to redirect to login page

        Suave_Shiva wrote:

        Also when user logged, click back button from browser & then clicking forward button,the session should expire & made him to Relogin again

        you hook on unload event in body tag of the page. So when user clicks on Back -> you send a request to server to remove session object Hope u get the idea << >>

        8x Solutions Ltd

        S 1 Reply Last reply
        0
        • W wEb GuRu

          In Web.config add... <sessionState timeout="10" />

          Lets work it Out.........!

          S Offline
          S Offline
          Suave_Shiva
          wrote on last edited by
          #4

          , this means session will expire after 10mins,ok.after 10mins,which page it should redirect?, where we hav 2 mention to redirect our login page(default page)?(was my question). Also the second Qtn was, when you sign in to a page, then if click 'back' button in the browser,it will directs to login page & if click 'forward' button ,it should not direct to the homepage,it should direct to login page,How is this possible?PLzzzzzzzzz send the code. Shiva

          1 Reply Last reply
          0
          • E enjoycrack

            As the previous poster => session expire after 10mins

            Suave_Shiva wrote:

            The session should expire after 10mins & should redirect to login page

            you should handle the session time out event to redirect to login page

            Suave_Shiva wrote:

            Also when user logged, click back button from browser & then clicking forward button,the session should expire & made him to Relogin again

            you hook on unload event in body tag of the page. So when user clicks on Back -> you send a request to server to remove session object Hope u get the idea << >>

            8x Solutions Ltd

            S Offline
            S Offline
            Suave_Shiva
            wrote on last edited by
            #5

            Hi Mr.8X Thank U for telling me in concept wise(internally) . I tried thru ur concept wise,but am not getting ,can u please send code or give me links, plzzzzzzzzzzzz. Hope u send me the solution............Thank U Shiva

            E 1 Reply Last reply
            0
            • S Suave_Shiva

              Hi Mr.8X Thank U for telling me in concept wise(internally) . I tried thru ur concept wise,but am not getting ,can u please send code or give me links, plzzzzzzzzzzzz. Hope u send me the solution............Thank U Shiva

              E Offline
              E Offline
              enjoycrack
              wrote on last edited by
              #6

              sorry, I have no full code for now - protected void Session_End(Object sender, EventArgs e) in Global to handle the session time out event - For onunload event: more info here http://www.w3schools.com/jsref/jsref_onunload.asp, in your handler function you open a window to make request to server to let server remove the session are these ok? << >>

              8x Solutions Ltd

              S 1 Reply Last reply
              0
              • E enjoycrack

                sorry, I have no full code for now - protected void Session_End(Object sender, EventArgs e) in Global to handle the session time out event - For onunload event: more info here http://www.w3schools.com/jsref/jsref_onunload.asp, in your handler function you open a window to make request to server to let server remove the session are these ok? << >>

                8x Solutions Ltd

                S Offline
                S Offline
                Suave_Shiva
                wrote on last edited by
                #7

                Thank U 4 ur cooperation & concept,but am unable 2 get wht i want the ouput,its not been logging out(session is not been ending,even if i unload). here's my code(without session declarations),can u create sessions & send me the code,take ur own time............but plzz send the code.......... => code of login page --------------------------------------------------------- protected void Button1_Click(object sender, EventArgs e) { try { OleDbConnection MsAccessCON = new OleDbConnection(ConfigurationManager.AppSettings["Con"]); OleDbCommand CMD = new OleDbCommand(); OleDbDataAdapter Adap = new OleDbDataAdapter("select * from Login",MsAccessCON); int i; int j; string ForUserName; string ForPassword; DataSet DS = new DataSet(); i = Adap.Fill(DS); DataTable DT = DS.Tables[0]; for (j = 0; j < i; j++) { ForUserName = Convert.ToString(DT.Rows[j][0]); ForPassword = Convert.ToString(DT.Rows[j][1]); ForUserName = ForUserName.Trim(); ForPassword = ForPassword.Trim(); if (ForUserName == UserNameTxtBx.Text && ForPassword == PwdTxtBx.Text) { Response.Redirect("HomePage.aspx?hi" + HttpUtility.UrlEncode(UserNameTxtBx.Text)); break; } if (ForUserName == UserNameTxtBx.Text && ForPassword != PwdTxtBx.Text) { ErrorLbl.Text = "Invalid Password"; break; } } if (j == i) { ErrorLbl.Text = "Invalid Username & Password"; UserNameTxtBx.Focus(); } // MsAccessCON.Close(); } catch (SystemException Ex) { Console.WriteLine(Ex.ToString()); } --------------------------------------------------------- homepage code: --------------------------------------------------------- logout as taken as link (when i click logout,i declared url to redirect to the login page) --------------------------------------------------------- In "web.config: I declared time=1", 2 expire session time. can u create session object & unload event for this code..........plzzzzzzzz From Shiva to 8x Solutions Ltd

                E 1 Reply Last reply
                0
                • S Suave_Shiva

                  Thank U 4 ur cooperation & concept,but am unable 2 get wht i want the ouput,its not been logging out(session is not been ending,even if i unload). here's my code(without session declarations),can u create sessions & send me the code,take ur own time............but plzz send the code.......... => code of login page --------------------------------------------------------- protected void Button1_Click(object sender, EventArgs e) { try { OleDbConnection MsAccessCON = new OleDbConnection(ConfigurationManager.AppSettings["Con"]); OleDbCommand CMD = new OleDbCommand(); OleDbDataAdapter Adap = new OleDbDataAdapter("select * from Login",MsAccessCON); int i; int j; string ForUserName; string ForPassword; DataSet DS = new DataSet(); i = Adap.Fill(DS); DataTable DT = DS.Tables[0]; for (j = 0; j < i; j++) { ForUserName = Convert.ToString(DT.Rows[j][0]); ForPassword = Convert.ToString(DT.Rows[j][1]); ForUserName = ForUserName.Trim(); ForPassword = ForPassword.Trim(); if (ForUserName == UserNameTxtBx.Text && ForPassword == PwdTxtBx.Text) { Response.Redirect("HomePage.aspx?hi" + HttpUtility.UrlEncode(UserNameTxtBx.Text)); break; } if (ForUserName == UserNameTxtBx.Text && ForPassword != PwdTxtBx.Text) { ErrorLbl.Text = "Invalid Password"; break; } } if (j == i) { ErrorLbl.Text = "Invalid Username & Password"; UserNameTxtBx.Focus(); } // MsAccessCON.Close(); } catch (SystemException Ex) { Console.WriteLine(Ex.ToString()); } --------------------------------------------------------- homepage code: --------------------------------------------------------- logout as taken as link (when i click logout,i declared url to redirect to the login page) --------------------------------------------------------- In "web.config: I declared time=1", 2 expire session time. can u create session object & unload event for this code..........plzzzzzzzz From Shiva to 8x Solutions Ltd

                  E Offline
                  E Offline
                  enjoycrack
                  wrote on last edited by
                  #8

                  - to create session: Session.Add("login",objLogin) //you can put any object into the Session state - to destroy the session object: Session["login"]=null; //set it to be NULL try these??? << >>

                  8x Solutions Ltd

                  S 1 Reply Last reply
                  0
                  • E enjoycrack

                    - to create session: Session.Add("login",objLogin) //you can put any object into the Session state - to destroy the session object: Session["login"]=null; //set it to be NULL try these??? << >>

                    8x Solutions Ltd

                    S Offline
                    S Offline
                    Suave_Shiva
                    wrote on last edited by
                    #9

                    Still i didn't completed that task,its in ending...........am able 2 end the session using timeout,ok.But.......... I tried to kill the session when i click back button(by writing the code in load event),so that i had to login again when i click forward button.But the code is not working..............plzz check the code code: ----------------- In Login Page: in the load event if(session["Login"]==null) session.abondon(); (tried also Session["Login"]=null;) & Coming 2 code in the homepage,in the load event if(session["Login"]==null) Response.redirect("Loginpage.aspx"); ----------------------- Hope U can solve my problem.......plzzzzzzzzzzzzzzzzzzzzzzz Thank U 4 everything.till now........ Urs Shiva

                    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