javascript - Set cookie while loading remote js in the domain where js is hosted -
below scenario looking at:
- i remotely loading js file site
hello.com
. - the js loaded
jsfoo.com
. - i want set cookie domain jsfoo.com in users browser when user visiting
hello.com
?
is possible within js file loaded or have write server side logic when loading js?
the objective retarget user visited hello.com
when user vists jsfoo.com
later.
update based on comment below: possible if js loaded dynamically? example if load js via dynamic url jsfoo.com/getjs.php?js=sample.js. wouldn't possible code set , cookies jsfoo.com via php code?
the js code executed under domain, can not set cookie client-side. possible if script resource loaded other domain sets cookie domain via http response header.
and won’t able access cookie of jsfoo.com in hello.com. if need existing value, script on jsfoo needs read when request domain happens, , return value in way js can read (f.e. outputting js variable.)
Comments
Post a Comment