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. Doubt on Cookie - asp.net 2.0

Doubt on Cookie - asp.net 2.0

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasecollaborationtools
7 Posts 3 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.
  • K Offline
    K Offline
    Karan_TN
    wrote on last edited by
    #1

    hi, currently i m using asp.net 2005 (framework 2.0) i m going to use the cookie for the 1st time in my project (its intranet productivity tool). i need some clarifications... 1. Can we go with Sessions or Cookies? which is best one? 2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one. 3. Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table? help me plz - KARAN

    B 1 Reply Last reply
    0
    • K Karan_TN

      hi, currently i m using asp.net 2005 (framework 2.0) i m going to use the cookie for the 1st time in my project (its intranet productivity tool). i need some clarifications... 1. Can we go with Sessions or Cookies? which is best one? 2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one. 3. Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table? help me plz - KARAN

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Karan_TN wrote:

      1. Can we go with Sessions or Cookies? which is best one?

      You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.

      Karan_TN wrote:

      2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.

      One need to give specific time to Expiresproperty so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are called Persistent cookies, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET Cookies

      Karan_TN wrote:

      Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?

      For this, use session There is two method in Global.asax file one is Session_Start and another is Session_End.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can use Session_End and you can get all those values that you said and can update in datatbase from here only. Let me know if any issue

      Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

      modified on Tuesday, April 20, 2010 2:23 AM

      K A 2 Replies Last reply
      0
      • B Brij

        Karan_TN wrote:

        1. Can we go with Sessions or Cookies? which is best one?

        You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.

        Karan_TN wrote:

        2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.

        One need to give specific time to Expiresproperty so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are called Persistent cookies, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET Cookies

        Karan_TN wrote:

        Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?

        For this, use session There is two method in Global.asax file one is Session_Start and another is Session_End.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can use Session_End and you can get all those values that you said and can update in datatbase from here only. Let me know if any issue

        Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

        modified on Tuesday, April 20, 2010 2:23 AM

        K Offline
        K Offline
        Karan_TN
        wrote on last edited by
        #3

        thanks a lot brij. got cleared with all my doubts. As per your guidance, i will go with sessions itself and take care to remove it at proper place to utilize the memory :) hope i m right. THANKS A LOT!

        B 1 Reply Last reply
        0
        • K Karan_TN

          thanks a lot brij. got cleared with all my doubts. As per your guidance, i will go with sessions itself and take care to remove it at proper place to utilize the memory :) hope i m right. THANKS A LOT!

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          your most welcome :)

          Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

          1 Reply Last reply
          0
          • B Brij

            Karan_TN wrote:

            1. Can we go with Sessions or Cookies? which is best one?

            You can use either one.Better to go for Session because cookies might be disabled at some browser so may not work properly.

            Karan_TN wrote:

            2. If i set cookie expire time as 1 hour, then after 1 hour will it expire? OR every time when user using the application it will retain its time, so that when user didnt work for 1 hour it will get expire? which is right one.

            One need to give specific time to Expiresproperty so it will expire at that time only.So it doesn,t matter whether user works for an hour or not.These are called Persistent cookies, if you set the expires time then it will there in browsers memory and will be removed when one close the browser, these are called <code>Non Persistent cookies</code> and stored on Browser memory while persistent one stored in local hard disk. for details in Cookies, have a look Beginner's Guide To ASP.NET Cookies

            Karan_TN wrote:

            Also i want to capture the applications logout time of individual user. so when session expire, can i get those values (say, loginID;team name;department name etc...) and update in my database table?

            For this, use session There is two method in Global.asax file one is Session_Start and another is Session_End.Session_Start is called whenevr any new session is getting created and Session_End is called whenever a session ends, so for your requirement you can use Session_End and you can get all those values that you said and can update in datatbase from here only. Let me know if any issue

            Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

            modified on Tuesday, April 20, 2010 2:23 AM

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

            Brij wrote:

            for details in viewstate, have a lookBeginner's Guide To ASP.NET Cookies

            Small Correction Brij, It should be "For details of Cookies" not ViewState:laugh:

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

            B 1 Reply Last reply
            0
            • A Abhijit Jana

              Brij wrote:

              for details in viewstate, have a lookBeginner's Guide To ASP.NET Cookies

              Small Correction Brij, It should be "For details of Cookies" not ViewState:laugh:

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

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

              Thanks for pointing it out. Updated :) Anyways that is your article only :)

              Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

              modified on Tuesday, April 20, 2010 2:57 AM

              A 1 Reply Last reply
              0
              • B Brij

                Thanks for pointing it out. Updated :) Anyways that is your article only :)

                Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

                modified on Tuesday, April 20, 2010 2:57 AM

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

                Yes. Thanks :thumbsup:

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

                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