본 사이트는 여러분의 사용자 경험을 개선하기 위해 유지 보수를 진행하는 동안 기능이 제한됩니다. 도움말로 문제가 해결되지 않고 질문을 하고 싶다면 Twitter의 @FirefoxSupport 및 Reddit의 /r/firefox 채널을 활용하세요.

Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

How to delete cookie using javascript

  • 4 답장
  • 16 이 문제를 만남
  • 5 보기
  • 최종 답변자: shivshankar.k

more options

Hi All,

I am working UI Automation. We are using javascript injection for automation. One of the features we need is to ability set / unset cookies.

I am able to set cookie using javascript, but I can't delete / unset a cookie. I am using below script to unset cookie.

document.cookie = 'cookie_name=; path=/; domain=.mycompany.com; expires=Thu, 01 Jan 1970 00:00:00 GMT';

If I try to alert document.cookie, it shows empty string. However, I can still see the cookie in browser after the javascript execution is complete.

Can someone suggest what I might be doing wrong?

P.S. I am on FF v17.0.3 esr on RHEL 5.

Thanks, Shiv

Hi All, I am working UI Automation. We are using javascript injection for automation. One of the features we need is to ability set / unset cookies. I am able to set cookie using javascript, but I can't delete / unset a cookie. I am using below script to unset cookie. document.cookie = 'cookie_name=; path=/; domain=.mycompany.com; expires=Thu, 01 Jan 1970 00:00:00 GMT'; If I try to alert document.cookie, it shows empty string. However, I can still see the cookie in browser after the javascript execution is complete. Can someone suggest what I might be doing wrong? P.S. I am on FF v17.0.3 esr on RHEL 5. Thanks, Shiv

모든 댓글 (4)

more options

Hey Shiv- This forum is for issues with the browser. However, I was able to find this article on MDN, which may help you:

https://developer.mozilla.org/en-US/docs/Web/API/document.cookie

Good luck!

more options

Thanks rbillings for responding. My code does exactly what is mentioned in that link, but no luck.

You mentioned that this forum is for issues related to browser. Is my question not in that category ? If not, can you please help me point to correct forum ? Thanks for bearing with newbie questions :)

Many Thanks, Shiv

more options

Hi Shiv- Your question involves the browser, but is more about UI automation & javascript. It requires help with code, and this forum is designed to help with UI, not code. I would recommend using sites that help with code [such as stackoverflow] to get more feedback about your specific issue. Sorry there isn't a forum for automation [and we're always glad to hear from newbies!]

more options

Got you, thanks so much :)