4 Replies Latest reply on Feb 12, 2010 9:05 AM by matthew stuart

    Hide region when user logged in

    matthew stuart Level 2

      Hi, I have a username and passwod box that I want to hide from view once the user is logged in. They on every page so it is easy for the user to log in from any page on my site.

       

      Once they are logged in, how do I hide the boxes and the associated form once the user is logged in, but once they log out, or close the browser window, I need the boxes to display again forcing the user to sign in again.

       

      I have run the DW log in user behaviour which works fine, I just don't know how to show or hide the boxes based on log in status.

       

      Any advice will be appreciated.

       

      Thanks.

       

      Mat

        • 1. Re: Hide region when user logged in
          Mylenium Most Valuable Participant

          You need cookies or session IDs for that. Then you can hide the DIV containing the log-in area based on a simple if()else() test based on a value stored...

           

          Mylenium

          • 2. Re: Hide region when user logged in
            matthew stuart Level 2

            OK, so I guess I would have something like the following up above the html declaration:

             

            <%
            Dim LogInSessionID
            LogInSessionID = Session.SessionID
            %>

             

            and then I would call upon it with something like this on the page:

             

            <%IF (LogInSessionID) = "No" Then%>

             

            Log in boxes

             

            <%Else%>

             

            Log out

             

            <%End if%>

             

            I get the idea of it to a degree, but I just don't know how to connect the two together. Understanding sessions has never been a strong point of mine. I don't understand how the session knows the user is not logged in. How does it know to look for and understand that "No" means the user is not logged in? Do I have to do something with my database?

             

            I'm probably opening a can of worms here, but I need to know.

             

            Thanks.

             

            Mat

            • 3. Re: Hide region when user logged in
              bregent Most Valuable Participant

              If you are using the DW login SB, you don't need to create any additional session variables. Just check if the MM_Username variable is populated:

               

              If Session("MM_Username") <> "" Then

              • 4. Re: Hide region when user logged in
                matthew stuart Level 2

                Excellent Bregent... as simple as that, and I can apply it to a SSI and it works a treat without having to update the whole site.

                 

                Thanks for your reply.

                 

                Mat