Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

javascript - Can cookies be read by third parties?

So I want to pass a random number generated by the js script I wrote, the information has to be hidden until passed to my php script, after that it can be displayed publicly, is it possible for someone to see the information the cookie is holding? If it is possible is there a way to pass information from js to php without anyone being able to see it? Edit- I might've done it wrong but I basically want to make a roulette with hashing and such, I have the hashing done on php and I'd like to animate the roulette using js, animating the roulette using js requires the number that the hashing process makes(I generate a random string and then hash it and use hexdec(substr($hash, 0, 8)) % 15; on it to make a number from it), I'm scared that someone will find out the hash before it reaches js and is animated, because after animation the hash is useless

question from:https://stackoverflow.com/questions/65920987/can-cookies-be-read-by-third-parties

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A very complex question. There are several ways in which information can be obtained. First, the browser itself has access to what it holds. We have no way of preventing this information from existing in the browser.

If your site is exposed to xss then you can run scripts on it. As a result, you will be able to access the information you have saved at the javascript level, cookies and everything around.

There is another attack that could be in the communication between the site and the "man in the middle" server. HTTPS communication can help you defend against attack.

Are there other ways? Probably so, it might be easier to help if we understand the exact challenge you are facing


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...