0

url with the issue
https://www.one.om/testtranslate

trying to delete all cookies named "googtrans"

when you select a language from the google translate dropdown, the page translates as expected, refresh the page to see the issue:

now there should be two cookies with the name "googtrans", but different domains:

domain 1: ".one.om"
domain 2: "www.one.om"

when i use

$.cookie('googtrans',null, {domain:'www.one.om'});

that works fine, but

$.cookie('googtrans',null, {domain:'.one.om'});

does not any suggestions?

Anton
  • 32,245
  • 5
  • 44
  • 54
Craig Wayne
  • 4,499
  • 4
  • 35
  • 50
  • I don't think this is possible because you are basically trying to change the main domain's cookie from a sub-domain. – Spokey Oct 10 '14 at 09:23
  • just tried it on https:// www.one.om and still no success – Craig Wayne Oct 10 '14 at 09:26
  • 1
    If you go to *one.om* you will be redirected to *www.one.om* before the script can run. Your domain has to be without the *www* – Spokey Oct 10 '14 at 09:27
  • story of my life with this site! so im assuming that modifying main domain cookies from subdomains is the source of the issue here – Craig Wayne Oct 10 '14 at 09:29
  • Yes, for security reasons the browser does not allow that. *www* is a sub-domain of *.one.com* but *.one.com* can delete any cookies from the sub-domains because it's the main domain name. I think there is a problem with the google script because of the domain redirection from without *www.* to *www.* and the cookie is set for both domains. – Spokey Oct 10 '14 at 09:32
  • ah i see your point... i will consider this resolved then. thanks spokey, i await your official answer – Craig Wayne Oct 10 '14 at 09:37

1 Answers1

5

Okay I think I managed to get it working. I might not get it correctly, but according to this topic it should be possible.

Please try and use the code below, it worked for me on Chromium (I modified the code from here):

function createCookie(name, value, days, domain) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    } else {
        var expires = "";
    }
    document.cookie = name + "=" + value + expires + "; domain=" + domain + "; path=/";
}

function eraseCookie(name, domain) {
    createCookie(name, "", -1, domain);
}

and then call:

eraseCookie("googtrans", ".one.om"); //erases the .one.om domain cookie
eraseCookie("googtrans", ""); //erases the www.one.om domain cookie

Please let me know if that worked for you.

Community
  • 1
  • 1
wap300
  • 2,660
  • 1
  • 16
  • 25
  • can i have your babies?! sorry, i know we're not supposed to have a question within a question! this worked for me on chrome for mac... gonna give it a go on the other browsers. thanks! :) – Craig Wayne Oct 10 '14 at 09:58
  • I will not give you my babies Craig ;) Great news though, glad that it worked! – wap300 Oct 10 '14 at 10:01
  • #rats! so i can confirm, this works for the following browsers on mac: Chrome, Firefox, Safari & Opera! Thank you once again @wap300 saved me hours! – Craig Wayne Oct 10 '14 at 10:14