• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to set a CFCOOKIE without a page reload?

Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

Is there a way to set a CFCOOKIE without a page reload when a user clicks a button/link/whatever? For example, an 'Add to cart' link.

Thanks!
TOPICS
Advanced techniques

Views

730

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jun 27, 2008 Jun 27, 2008
Got it figured out. Here is an example in case anyone else would happen to need it.

Votes

Translate

Translate
Community Expert ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

I don't understand. Doesn't a page reload "when a user clicks a button/link/whatever? "

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

This is just a guess, but I bet you could set a cookie with Javascript and then access it later with cfcookie if you worked it right.

D

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

Just do <cfcookie> on the page the button/link/whatever is pointing to.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2008 Jun 26, 2008

Copy link to clipboard

Copied

BKBK, I'm pretty sure OldNapkin is saying he/she wants to use ajax remoting on the page or something so that the entire page doesnt reload, but cfcookie doesnt work until after the page reloads...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 27, 2008 Jun 27, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: Dstharding
BKBK, I'm pretty sure OldNapkin is saying he/she wants to use ajax remoting on the page or something so that the entire page doesnt reload, but cfcookie doesnt work until after the page reloads...


That is exactly what I want to do. Can I use AJAX to call a Cookie-setting CFC with a click?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 27, 2008 Jun 27, 2008

Copy link to clipboard

Copied

Got it figured out. Here is an example in case anyone else would happen to need it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2008 Jun 27, 2008

Copy link to clipboard

Copied

Dstharding, then your Javascript guess is good (document.cookie="username=BKBK; loggedIn=yes";)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 28, 2008 Jun 28, 2008

Copy link to clipboard

Copied

LATEST
A couple of points.

1) I don't think there should be a forward slash in the bind expression.
2) Your client code suggests the client determines the cookie value. Isn't that bad?
3) Though using 'value' as an attribute of <div> might work, 'value' is not an attribute of the tag.
4) Why all the HTML? Isn't something like the following sufficient?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation