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. clearing cookies on browser close

clearing cookies on browser close

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorial
12 Posts 5 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.
  • A Offline
    A Offline
    amarnath n n
    wrote on last edited by
    #1

    Hi All, I have one doubt, how to clear the cookies on browser closing in asp.net

    A M B 3 Replies Last reply
    0
    • A amarnath n n

      Hi All, I have one doubt, how to clear the cookies on browser closing in asp.net

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      There is no way to trap Browser close event of the client as per I know. You can clear cookie during sign off. :rose:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      A M A 3 Replies Last reply
      0
      • A Abhishek Sur

        There is no way to trap Browser close event of the client as per I know. You can clear cookie during sign off. :rose:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        A Offline
        A Offline
        amarnath n n
        wrote on last edited by
        #3

        Thank you for your suggestion but i already did that.I have to do the same in browser close also.

        1 Reply Last reply
        0
        • A Abhishek Sur

          There is no way to trap Browser close event of the client as per I know. You can clear cookie during sign off. :rose:

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          M Offline
          M Offline
          Manas Bhardwaj
          wrote on last edited by
          #4

          Abhishek Sur wrote:

          There is no way to trap Browser close event of the client as per I know.

          AFAIK, there is. :)

          Abhishek Sur wrote:

          You can clear cookie during sign off

          Which sign off? :doh:

          Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

          A A 2 Replies Last reply
          0
          • A amarnath n n

            Hi All, I have one doubt, how to clear the cookies on browser closing in asp.net

            M Offline
            M Offline
            Manas Bhardwaj
            wrote on last edited by
            #5

            amarnath n.n wrote:

            how to clear the cookies on browser closing in asp.net

            If you don't set an expiry date, the cookie will be a 'session cookie' so will be deleted when the browser session ends.

            Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

            A 1 Reply Last reply
            0
            • A amarnath n n

              Hi All, I have one doubt, how to clear the cookies on browser closing in asp.net

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              On onbeforeunload event of body loop all cookies and set expire date.That will do the trick.


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

              A 1 Reply Last reply
              0
              • M Manas Bhardwaj

                Abhishek Sur wrote:

                There is no way to trap Browser close event of the client as per I know.

                AFAIK, there is. :)

                Abhishek Sur wrote:

                You can clear cookie during sign off

                Which sign off? :doh:

                Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                Manas Bhardwaj wrote:

                Abhishek Sur wrote: There is no way to trap Browser close event of the client as per I know. AFAIK, there is. Smile

                Manas, you are correct, I have done this think a quite time before :)

                function CheckBrowserClose()
                {

                , Alt+F4 , File -> Close

                if(window.event.clientX < 0 && window.event.clientY <0)
                {

                }
                }

                And called it on Body unload ;)

                Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

                1 Reply Last reply
                0
                • B Blue_Boy

                  On onbeforeunload event of body loop all cookies and set expire date.That will do the trick.


                  I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                  A Offline
                  A Offline
                  Abhijit Jana
                  wrote on last edited by
                  #8

                  Blue_Boy wrote:

                  set expire date

                  :thumbsup: This is all about the Trick. Set the Cookies expire date, and just relaxed. :laugh:

                  Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

                  1 Reply Last reply
                  0
                  • M Manas Bhardwaj

                    amarnath n.n wrote:

                    how to clear the cookies on browser closing in asp.net

                    If you don't set an expiry date, the cookie will be a 'session cookie' so will be deleted when the browser session ends.

                    Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

                    A Offline
                    A Offline
                    Abhijit Jana
                    wrote on last edited by
                    #9

                    Good Answer. And I think, rather than waiting to browser do it set expire date is better option ;)

                    Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

                    1 Reply Last reply
                    0
                    • A Abhishek Sur

                      There is no way to trap Browser close event of the client as per I know. You can clear cookie during sign off. :rose:

                      Abhishek Sur


                      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                      **Don't forget to click "Good Answer" if you like to.

                      A Offline
                      A Offline
                      Abhijit Jana
                      wrote on last edited by
                      #10

                      Abhishek Sur wrote:

                      There is no way to trap Browser close event of the client as per I know.

                      We can ;). Check my reply to Manas's post !! :)

                      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

                      A 1 Reply Last reply
                      0
                      • A Abhijit Jana

                        Abhishek Sur wrote:

                        There is no way to trap Browser close event of the client as per I know.

                        We can ;). Check my reply to Manas's post !! :)

                        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

                        A Offline
                        A Offline
                        Abhishek Sur
                        wrote on last edited by
                        #11

                        Oh.. got it bro.. Thanks for correcting me. :rose:

                        Abhishek Sur


                        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                        **Don't forget to click "Good Answer" if you like to.

                        1 Reply Last reply
                        0
                        • M Manas Bhardwaj

                          Abhishek Sur wrote:

                          There is no way to trap Browser close event of the client as per I know.

                          AFAIK, there is. :)

                          Abhishek Sur wrote:

                          You can clear cookie during sign off

                          Which sign off? :doh:

                          Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

                          A Offline
                          A Offline
                          Abhishek Sur
                          wrote on last edited by
                          #12

                          Hey manas.. Thanks for correcting me. :thumbsup:

                          Abhishek Sur


                          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                          **Don't forget to click "Good Answer" if you like to.

                          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