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. Session

Session

Scheduled Pinned Locked Moved ASP.NET
16 Posts 4 Posters 1 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.
  • _ _AK_

    //Normally this is how we store and retrieve sessions Session["Test"] = "Storing a string"; //Retrieving a string string sTemp = Session["Test"]; Best Regards, Apurva Kaushal

    S Offline
    S Offline
    Socheat Net
    wrote on last edited by
    #5

    I tried as you not ok. Example all my page I have write If Username="" or Password="" Then Response.Redirect("Login.aspx") End If If user login successed and continue to another page my session not good the page will be redirect to Login.aspx I used in Global.asax Help me? ................

    _ 2 Replies Last reply
    0
    • S Socheat Net

      I tried as you not ok. Example all my page I have write If Username="" or Password="" Then Response.Redirect("Login.aspx") End If If user login successed and continue to another page my session not good the page will be redirect to Login.aspx I used in Global.asax Help me? ................

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #6

      Hi, Actually what you need to do is whenever a user successfully logs in then you have to put the user name and password in session(if you want to access it some where). And when ever the moves to the next page then you have to check in session whether that is available or not if not then redirect him to the login page. Best Regards, Apurva Kaushal

      S 2 Replies Last reply
      0
      • S Socheat Net

        I tried as you not ok. Example all my page I have write If Username="" or Password="" Then Response.Redirect("Login.aspx") End If If user login successed and continue to another page my session not good the page will be redirect to Login.aspx I used in Global.asax Help me? ................

        _ Offline
        _ Offline
        _AK_
        wrote on last edited by
        #7

        Hi, Go through these links it will be helpful. http://webmonkey.wired.com/webmonkey/03/30/index3a.html?tw=programming http://coveryourasp.com/Session.asp Best Regards, Apurva Kaushal

        S 1 Reply Last reply
        0
        • _ _AK_

          Hi, Actually what you need to do is whenever a user successfully logs in then you have to put the user name and password in session(if you want to access it some where). And when ever the moves to the next page then you have to check in session whether that is available or not if not then redirect him to the login page. Best Regards, Apurva Kaushal

          S Offline
          S Offline
          Socheat Net
          wrote on last edited by
          #8

          Can u give my an example? ................

          _ 1 Reply Last reply
          0
          • S Socheat Net

            Can u give my an example? ................

            _ Offline
            _ Offline
            _AK_
            wrote on last edited by
            #9

            I think the link which i have given is having exactly the example you are looking for. Go to the second page of that you will get that: http://webmonkey.wired.com/webmonkey/03/30/index3a\_page2.html?tw=programming Best Regards, Apurva Kaushal

            1 Reply Last reply
            0
            • _ _AK_

              Hi, Actually what you need to do is whenever a user successfully logs in then you have to put the user name and password in session(if you want to access it some where). And when ever the moves to the next page then you have to check in session whether that is available or not if not then redirect him to the login page. Best Regards, Apurva Kaushal

              S Offline
              S Offline
              Socheat Net
              wrote on last edited by
              #10

              Can u gime me example? ................

              1 Reply Last reply
              0
              • _ _AK_

                Hi, Go through these links it will be helpful. http://webmonkey.wired.com/webmonkey/03/30/index3a.html?tw=programming http://coveryourasp.com/Session.asp Best Regards, Apurva Kaushal

                S Offline
                S Offline
                Socheat Net
                wrote on last edited by
                #11

                it is correct that i wrote in global.asax Sub Session_onStart() Dim Username As String DIm Password As String Session("Username") ="No" Session("Password") ="No End Sub after i use in admin page for user login If Username="Socheat" And Password="123456" The Session("Username") = "Yes" Session("Password") = "No" End If Some other page like this ................

                _ 1 Reply Last reply
                0
                • S Socheat Net

                  it is correct that i wrote in global.asax Sub Session_onStart() Dim Username As String DIm Password As String Session("Username") ="No" Session("Password") ="No End Sub after i use in admin page for user login If Username="Socheat" And Password="123456" The Session("Username") = "Yes" Session("Password") = "No" End If Some other page like this ................

                  _ Offline
                  _ Offline
                  _AK_
                  wrote on last edited by
                  #12

                  Why are you putting it in global.asax file? how are you getting the user credentials? Best Regards, Apurva Kaushal

                  S 1 Reply Last reply
                  0
                  • _ _AK_

                    Why are you putting it in global.asax file? how are you getting the user credentials? Best Regards, Apurva Kaushal

                    S Offline
                    S Offline
                    Socheat Net
                    wrote on last edited by
                    #13

                    where can i put it? ................

                    _ 1 Reply Last reply
                    0
                    • _ _AK_

                      Hi, You put user name and password in session and check it in all the pages from session. Best Regards, Apurva Kaushal

                      S Offline
                      S Offline
                      Sushant Duggal
                      wrote on last edited by
                      #14

                      Hi, Use it like this: Session["username"] = txtUsername.Text; At other page load check: if(Session["username"] != null) { lblUsername.Text = Session["username"].ToString(); } I hope it helps you Sushant Duggal.

                      1 Reply Last reply
                      0
                      • S Socheat Net

                        Can u give me an example? ................

                        M Offline
                        M Offline
                        Mihai Drebot
                        wrote on last edited by
                        #15

                        best way to do this is make your own class describing a user, you might have there a user name, password, real name, email, etc, some login methods, whatever else you think you need to know about the user (don't exagerate here, if you have zounds of users logged at the same time, you will have a load problem). You can store the user object on the session, retrieve it from there using an explicit cast, with no trouble at all. Just make sure the user object is serializable if you keep the session in the sql server.

                        1 Reply Last reply
                        0
                        • S Socheat Net

                          where can i put it? ................

                          _ Offline
                          _ Offline
                          _AK_
                          wrote on last edited by
                          #16

                          If you are providing any login screen then on after you verifies the user put them in session may be on the login button click event. and on the other page you can check like that name is available or not in the session if present then the user is authorized. Best Regards, Apurva Kaushal

                          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