Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Javascript Cookies


  • Please log in to reply
9 replies to this topic

#1 JUICYboy

JUICYboy

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:06:16 PM

Posted 11 January 2011 - 10:35 PM

I am researching and developing my understanding of Javascript and I had a question on Javascript cookies.

Once a Javascript cookie is set on this example, how can someone cancel that cookie?
http://www.w3schools.com/js/tryit.asp?filename=tryjs_cookie_username

In the example once the cookie is set, every time the page is visited it remembers the input. But how about if I was another user and I wanted it to have a way to change the user name or just "cancel" the cookie. So that next log in it will not remember my input.

Unfortunately it did not explain this.

Thank-you :inlove:

Edited by JUICYboy, 11 January 2011 - 10:36 PM.


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:16 PM

Posted 12 January 2011 - 10:03 AM

You can do three things with cookies; you can set a cookie, you can read a cookie, and you can delete a cookie.

#3 Eyesee

Eyesee

    Bleepin Teck Shop


  • BC Advisor
  • 3,541 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:In the middle of Kansas
  • Local time:05:16 PM

Posted 12 January 2011 - 05:50 PM

Four things actually:
You can also eat a cookie

Sorry Groovicus I couldnt pass that one up!

I'll go stand in the corner for punishment now!!
In the beginning there was the command line.

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:16 PM

Posted 12 January 2011 - 08:19 PM

You forgot bake a cookie, toss your cookies, etc. :hysterical:

#5 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:05:16 PM

Posted 12 January 2011 - 08:19 PM

You can set the expiry time of the cookie to be shorter so it expires after that time. Its as good as deleting the cookie but it happens automatically.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:16 PM

Posted 12 January 2011 - 09:39 PM

You have to create a new cookie with the same name/value pair as the one you want to update, and then set the expiration time to -1. What that does is deletes the existing cookie with the same name/value pair, and creates a new cookie with the new timeout value. :) Not sure if you were inferring that you could update a cookie or not, because you can't, at least AFAIK.

Edited by groovicus, 13 January 2011 - 06:48 AM.


#7 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:06:16 PM

Posted 13 January 2011 - 09:51 AM

As I have done my research cookies are used to store log-in information, or times a user has traveled to the site.

Is there anything else cookies can be used for? :mellow:

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:16 PM

Posted 13 January 2011 - 10:44 AM

Why don't you look at the cookies stored by your browser and see for yourself?

#9 blondie101010

blondie101010

  • Members
  • 7 posts
  • OFFLINE
  •  
  • Local time:05:16 PM

Posted 14 January 2011 - 10:14 PM

As I have done my research cookies are used to store log-in information, or times a user has traveled to the site.

Is there anything else cookies can be used for? :mellow:


In normal context, cookies should only be used to store very little information like a user identifier, language and the such. Other variables should be managed in the back-end for security reasons.

#10 ThunderZ

ThunderZ

  • Deactivated
  • 4,454 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:05:16 PM

Posted 14 January 2011 - 10:53 PM

Is there anything else cookies can be used for? :mellow:



While the example given pertaining to "evercookie" is an extrem example, the answer to your question is yes.

Edited by ThunderZ, 14 January 2011 - 10:54 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users