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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read a CFCOOKIE via JavaScript?

Status
Not open for further replies.

PaulSc

MIS
Aug 21, 2000
148
0
0
GB
Hi,
I wonder if anyone can help me please...

I'm working on a CF based application which has a login/logged-in type dialog on each page.

the login code (which cannot be changed(!)) sets a cookie using CFCOOKIE, subsequent pages then check for the existance of this cookie using the <CFIF IsDefined("cookie. syntax.

We are trying to make the site as 'static' as possible, so are looking at converting this to a clientside javascript

Can anybody suggest a way of reading the cfcookie?? I've tried normal cookie reading scripts but it can't seem to read CFCOOKIES???

Thanks

PaulSc
 
I've tried normal cookie reading scripts but it can't seem to read CFCOOKIES???

I've never had cfcookies are they any good?

Cfcookie just makes a cookie, same as any other language. in the end a cookie is no different than a "cfcookie" which is just the method of creating the cookie. It isn't actually a different type of cookie.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Um...

I've heard lots of times someone having this issue... cookies aren't very compatible (between cf and js) at least.

I don't get it though...

A.) You mean to say you're relying on javascript for security? That's bad...

B.) If its static, where does cf come into play at all? I think what you're saying is that you have cfm pages that you want to read the cookie with js. The bad part is that you count do anything useful in cf reading the cookie via javascript.

To be literal, are you just trying to avoid having to use:

<cfoutput>#cookie.thecookie#</cfoutput>? If so, and that's what it sounds like, that one read to the cookie is not going to affect things.

Curious though, are you setting the EXPIRES attribute of the cookie?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Hi,
no we dont...it gets deleted when they log off...hm must review this!!

a/the cookie doesnt control security as such, just some personalisation.

b/the login dialog is a subpart of a cf/commonspot template.
We are using a system called Commonspot (a content management system) to serve the pages and this caches the complete page, hence when they first access the page it shows a login prompt, when they logon and return to the page it still shows logon (page is served from the server not local cache so only gets refreshed when the server is updated..hence the requirement to render the page locally..) despite them being logged in already.

What we are trying to do is to 'create' the login dialog via clientside javascript, checking the cookie and then using if/else and document.writes to write out the appropriate links..

weve got the base logic working but cant seem to read the b###dy cookie......I take it that the CFCOOKIE name parameter is the same name you use in JS to reference it??

Any other solutions to this???

Thanks.

PaulSc

 
I know very little about js cookies... I didn't like them when I tried them a few years ago so I'm no expert.

The expires attribute may be whats kicking you... Its setting the cookie in memory rather than on file and JS isn't reading out of memory.

Its a possibility... Not likely, but possible.

Expires can be an integer (expires="3") to represent the number of days for the life of the cookie. It can be "never" which means that so long as the user doesn't clear the cookies and you don't write a script to delete it after all, its cleared, or if the expires attribute does not exist, then the cookie resides in memory til the browser is closed.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top