What would be the best way to handle ColdFusion Cookies from a javascript function?
I need to get and set the Cookie’s value.
I guess there is an alternative solution to using document.cookie ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Seems like the answer is if you’re in javascript you’d use document.cookie and if you’re in CFML you’d use cfcookie.
I suppose it depends on when you’re trying to do this really–if you’re doing this in a block of javascript when the page loads then you could use cfcookie since that would get parsed as the page renders, but after the page loads of course you can’t use cfcookie without another page load (if that makes sense).
On the flip side if you’re doing some behind the scenes processing in CFML of course you’d have to use cfcookie since doing in the javascript way might not be possible given the situation.
Honestly even in situations where you could do either it doesn’t matter. Both do the same thing so use whatever one makes most sense or makes the code most readable given the situation.