Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Do you put your faith in cookies?

    I have always EXPECTED cookie data to be good. For example, I will write "lb" or "kg" to a cookie to keep track of how my visitors weigh themselves. Then when they come back, I check for a cookie. If it's null, I default to "lb." But if it's not null, I use the data trusting that it will be good.

    I could check to see that it's "lb" or "kg" and then use it and default to "lb" if it's neither, but I've never bothered. I'm wondering if I should?

    I spent the better part of the day trying to find a problem which it turned out was caused by a browser. (The previous version of the WebTV simulator didn't store cookies at all; it seems that this one only stores part of them. Unless I'm somehow causing it but my code works fine with IE and N 4 & 7.)

    I was saving a cookie containing 18 data fields using "=" as a control code to separate them. Then EXPECTING to find all the data in the cookie I wrote I had a routine that read all 18 fields. Problem was, today there were only about 6. My website hung.

    I solved the problem with a simple routine to check for the 18 control codes. If I don't find all 18, I just don't use the cookie and use defaults as if it were null.

    I suppose I should start thinking about this possibility more often. I am not willing to code my site for a user without cookies enabled, but I don't want an occasional failure to cause my site to crash.

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cookies are good for stuff that isn't incredibly important.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've never had any problems storing name=value& pairs in cookies (providing you escape the data before writing to the cookie); but all the same - it's much easier just to keep a session or user ID in the cookie, and store the user's data server-side.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Assuming you have a clue how to do anything on the server side.

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Storing data in client-side cookies is about only good for storing user preferences when you do not require them to login to your site. You obviously wouldn't want to store anything important or ciritical in them as chrismicelli suggested since users can disable cookies.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •