Are cookies preserved while doing windows.location(url)
, if domain of url is the domain of the current page?
window. location is an object that holds all the information about the current document location (host, href, port, protocol etc.). location. href is shorthand for window.
The location property of a window (i.e. window. location ) is a reference to a Location object; it represents the current URL of the document being displayed in that window. Since window object is at the top of the scope chain, so properties of the window.
The window. location object can be used to get the current page address (URL) and to redirect the browser to a new page.
To be really pedantic, changing window.location
in Javascript will cause the browser to go to another site, which includes making a GET request. In other words, a GET request and Javascripts window.location
are two completely different things; one is a type of HTTP request, the other a DOM attribute.
As pertains to the question though, they can be considered equivalent. Cookies are preserved.
</pedantry>
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With