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

CFCOOKIE: trouble with DOMAIN & PATH

Status
Not open for further replies.

philcha

Programmer
May 10, 2000
109
GB
Hi, Can anyone help me with this?

I'm developing an app on my local PC (using PWS) but the app will be published on the web. This app will be one of several on the web site, so I want to use CFCOOKIE's PATH attribute to group cookies by app. So I need to specify the PATH attribute.

The trouble is that if I use the DOMAIN attribute (with or without PATH) my cookies don't get set. If I omit the DOMAIN attribute my cookies work but I can't use PATH to group them by app.

The PWS "site" does not have a full web domain name but appears in the browser address bar as and the CF diagnostic output shows CGI.HTTP_HOST=phil
(I understand that LANs behave in the same way, i.e. they show as e.g.
I inserted some debug output lines and they show what I expected, i.e. the code seems to be doing what I intended (whether that's right is another matter):
App.cfm:
Application.CookieDomain = |.phil|
Application.CookiePath = |/development/app1|
(I use | as a delimiter on debug output)

My development configuration is:
CF 4.0.1
Win 98 with PWS

I use this code in Application.cfm to set up the DOMAIN and PATH values:
<cfset Application.AppTopDir = &quot;app1&quot;>
<cfif NOT IsDefined(&quot;Application.CookiePath&quot;)>
<cfset PathLen = Find(Application.AppTopDir, Cgi.PATH_INFO) + Len(Application.AppTopDir) - 1>
<cfset Application.CookiePath = Left(Cgi.PATH_INFO, PathLen)>
</cfif>
<cfset Application.CookieDomain = &quot;.&quot; & Cgi.HTTP_Host>

and this code in OnRequestEnd.cfm to set a cookie:
<cfcookie name=&quot;CookieOK&quot; value=&quot;y&quot; domain=&quot;#Application.CookieDomain#&quot; path=&quot;#Application.CookiePath#&quot; secure=&quot;no&quot;>
(I've also tried setting the cookie in other places and it still doesn't work if I specify DOMAIN)

Can anyone suggest how I can set cookies with Domain & Path in my development environment?

Thanks,

Phil
 
Did you ever resolve this issue? I am having a similar problem and would like to get it to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top