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!

cfcookie working inconsistently

Status
Not open for further replies.

Lotruth

Programmer
May 2, 2001
133
0
0
US
I have a templete using cfcookie in my development folder and it works find. When I copy it up to the public folder and put it on the internet, it will not pass the cookie.
Any ideas why?

Thanks
 
What's your code look like? Are you setting an incorrect domain once it gets to the live server? Does your Application.cfm file look the same (the CFAPPLICATION tag)?
 
I pass a variable (button) from the previous page. On the second page, I have

<cfif button is yes>
<cfcookie name=&quot;view&quot; value=&quot;1&quot; expires=&quot;1&quot;>
</cfif>

At this point, it is fine(meaning #view#=1).
But whenever I hit a button on this page, I get an error saying that #view# is not defined.
This only happens on the live server.

I dont know what you mean by &quot;setting an incorrect domain&quot;

My application.cfm file looks nothing at all like the template in question.

Thanks for being patient with my ignorance.
 
Have you tried a very simple testing file? Make a file where all it does is set a cookie, then make another one that only checks and outputs the value of that cookie. Try both files on both servers.

I would also try
Code:
<cfif FORM.button IS &quot;yes&quot;>
though I'm not sure if that's what your code is asking. Is &quot;button&quot; a form variable from the page before? Is it's value &quot;yes&quot;?

I see you're not setting the domain in your
Code:
CFCOOKIE
tag, so you don't have to worry about the domain stuff.

I would first make sure your set of test files works. If they work and set your fake cookie on both servers, then something isn't working in your code. Let me know!
 
I simplified the code and tried it on both servers and still at works at the development level, but not the public level.

Here is my code for the form page:

<HTML>
<HEAD>

<TITLE>Form Selection</TITLE>
</HEAD>
<BODY>

<form action=&quot;testing1.cfm&quot; method=&quot;post&quot;>
<input type=&quot;submit&quot; value=&quot;First&quot; name=&quot;name&quot;>
</form>

<form action=&quot;testing1.cfm&quot; method=&quot;post&quot;>
<input type=&quot;submit&quot; value=&quot;Second&quot; name=&quot;name&quot;>
</form>

</BODY>
</HTML>

Here is my code for the action page:

<html>
<head>
<title>Test</title>
</head>

<body>
<cfif isdefined('name')>
<cfif name is 'first'>
<cfcookie name=&quot;view&quot; value=&quot;1&quot; expires=&quot;1&quot;>
<cfelseif name is 'second'>
<cfcookie name=&quot;view&quot; value=&quot;2&quot; expires=&quot;1&quot;>
</cfif>
</cfif>

View is <cfoutput>#view#</cfoutput>

<FORM ACTION=&quot;testing1.CFM&quot; METHOD=&quot;POST&quot;>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

</body>
</html>
 
Yep, that code should work just fine. So something is different on the new server. I looked around and found the following tips:

- If the date/time is not set correctly on the new server you may be setting cookies that immediately expire. I don't think that's it but it's worth checking.

- Might be just you, see (if you'd like to make the testing file public I'll be happy to try it).

- Looks like some people have issues getting cookies to set the first time with AOL, any chance that's involved?

- Some people suggest putting the optional attributes in (domain, path), have you tried that?

- If you set it to expires=&quot;NEVER&quot; will it work? Read something about that working where others fail.

- Does it not work in all browsers? Read about problems with IE and frames.

- Is there a proxy involved on this second server (or any load balancing not like the first server)? See
Hate to say it Lotruth but I think I'm at the end of my help with this one! My advice is to post the code for those two pages that you just posted, and tell them the symptoms. No reason I can think of why those test pages shouldn't work. Might also help your cause to make the testing pages live that don't work for you, so others can test them and give you their results.

Sorry! Let me know what happens, I'm interested...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top