There are many questions that seem to affect options for this issue. But they are usually complex, regular answers, and I hope I can find something simpler.
Given location.host values
foo.mysite.com app.foo.mysite.com mysite.com
How can I get the root domain of mysite.com
?
I could do something like search second to last .
but it seems ugly and will not work for any TLD such as .co.uk
. If jQuery has an object containing this information, I am glad to use it.
My goal is to create cookies that exist in all subdomains. For this I need to find .mysite.com
. I would rather not print it.
source share