Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFCOOKIE & Not CF Servers

Status
Not open for further replies.

jmcg

Technical User
Jun 30, 2000
223
GB
I have a page on a CF server that has set a cookie called Display.
Is it possible for this cookie to be viewed by a page that is not on a CF server.

IE what is the code for retrieving a CFCOOKIE in normal HTML/Javascript.

 
Cookies are only sent to servers that created them so other servers will not see them. There is an exception to this. If several servers are load balancing a site, cookies created on one can be seen by the other servers because they are all in theory the same site.

If you're coding in CF, I would use CF's cookie handling features as they do a lot of the decoding work for you that you would have to do manually in Javascript. Just use <cfset x = cookie.var1> to get a cookie called &quot;var1&quot;. In javascript, cookies are accessed by the document.cookie object and I believe it returns one long string containing all cookies and values which you have to split up and parse out yourself.

Hope this helps,
GJ
 
GJ
Thanks for the pointer.
As I was not too interested in the content of the cookie only that it existed you tip led me to :
Code:
function CheckCookie() {
	var allcookies = document.cookie;

	var pos = allcookies.indexOf(&quot;COOKIE1=&quot;);
	if (pos !=-1) {
		(do my thing)
		}
That meant I could ignore the parse bit.
Thanks
jmcg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top