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. Checking the size of a cookie

Checking the size of a cookie

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 2 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.
  • S Offline
    S Offline
    suzyb
    wrote on last edited by
    #1

    I want to write some tracking information to a cookie. When the cookie reaches it's max size I want to overwrite the final value or 2. How do I check the size of a cookie though.

    Z 1 Reply Last reply
    0
    • S suzyb

      I want to write some tracking information to a cookie. When the cookie reaches it's max size I want to overwrite the final value or 2. How do I check the size of a cookie though.

      Z Offline
      Z Offline
      Zaf Khan
      wrote on last edited by
      #2

      I guess the logical solution is to read the cookie into a string and check the length of the string using the LEN() Function. As long as you know waht the MAX permitted cookie size is, its simple to know if its at the maximum size.

      S 1 Reply Last reply
      0
      • Z Zaf Khan

        I guess the logical solution is to read the cookie into a string and check the length of the string using the LEN() Function. As long as you know waht the MAX permitted cookie size is, its simple to know if its at the maximum size.

        S Offline
        S Offline
        suzyb
        wrote on last edited by
        #3

        Thanks for the advice. What I've done is check for a little less than the max value though to allow for the other information (expiry etc) that is written with the cookie data.

        Z 1 Reply Last reply
        0
        • S suzyb

          Thanks for the advice. What I've done is check for a little less than the max value though to allow for the other information (expiry etc) that is written with the cookie data.

          Z Offline
          Z Offline
          Zaf Khan
          wrote on last edited by
          #4

          Given that you know already the NAME and VALUE of the data to be written to the cookie, Its not so difficult to check the length of the data (to be written) including the name and then subtract that from the maximum size allowable for the cookie and then you will know EXACTLY how space you have remaining (in the cookie) to work with.

          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