|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Cookie conflict between ColdFusion and Javascript
Hello,
I am having an interesting problem with my CF pages and I have found a workaround for it, but I don't know why it is happening. I use CF to create a cookie, then I use either cfcookie, cfset, or javascript to set the values in the pages (depending on my needs) However, sometimes when I use javscript to set the value and then try to use cfcookie or cfset, niether will set the value. The code is being triggered, it just won't set the value. If I access the page using a different page (one that doesn't kick off javascript) everything works fine. Anyone have any ideas? |
|
#2
|
|||
|
|||
|
Post code?
I have an idea as to why this might be happening, but I would need a further look at your code. Keep in mind the nature of these languages. Coldfusion is server-side (code is processed on the server) and javascript is client-side (code is processed on the users client machine). Keep this in mind when you are trying to figure out why some code works and some code doesnt.
Last edited by srdiesel : July 13th, 2004 at 11:00 AM. Reason: Oops spelling... |
|
#3
|
||||
|
||||
|
Well, while trying to hunt down a different problem I found why it wasn't working properly, and it wasn't a conflict, but rather my JS code not working properly.
When the code was suppose to be modifiy the existing cookie value, it was instead adding another cookie with the same name/value. |
|
#4
|
|||
|
|||
|
Cool
Ah! That'll do it. I can't even count how many times I post and then answer my own question lol. Happy you figured it out.
|
|
#5
|
||||
|
||||
|
Hmm, well as much as i have found why it wasn't working before, now i am running into a problem on why it is creating a second cookie. I have looked through the manuals of both languages, and i can't figure out why it is creating two. The code looks like this:
index.cfm has the following line to create the cookie: <cfcookie name="LOGGEDIN" value="YES"> Index.cfm then calls a frame set, which on unload will run the following script (which instead of updating, creates a new cookie with the same name): function SetCookie (name, value) { this.document.cookie = name + "=" + value; } I have tried many versions of this JS function (setting all the values, some of the values, encoding, etc) and none will udpate the original. any ideas? |
|
#6
|
|||
|
|||
|
Can you look at the actual text files of the cookies and see if they are different in some way (CF may give the cookie a CF-specific name, I'm not sure).
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#7
|
||||
|
||||
|
Well it depends, sometimes it will create both in the file, depending on how i create the cookie(tried cfcookie, cfset and JS). Sometimes it will only create one, sometimes both. But, if I use alert to show the values stored in document.cookie, it will always show the cookie twice.
|
|
#8
|
||||
|
||||
|
After some more digging, it is something between the two languages that is causing the problem. If i create/update the cookie with JS, then all is well. IF i create it with CF and then try to udpate with JS, that is when the dups happen.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Cookie conflict between ColdFusion and Javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|