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!

Cookies via java objects

Status
Not open for further replies.

iamkillyou

Programmer
Jul 12, 2001
30
0
0
US
Does anyone know how to create a java object in a cfscript block that will write a cookie?

I ask this because in my application I want to read or set, read to verify that I wrote one and increment a unique visitor counter.

The problem is the cookie scope - even if the visiting browser has cookies blocked CF is still reading the cookie scope, not the actualy cookie, resulting in an always true condition.

Normally this can be done in two templates, but since everyone comes into my site view different pages I have to do it in application.cfm.

I suppose I could use javascript to set the cookie, but I'd like to have a completley seerver side solution.

So my thoughts are to create the cookie in java something like this: (which I can't get to work)


Code:
<cfscript>
response = CreateObject("java", "java.lang.String");
myCookie = new Cookie("myVar","test"));
myCookie.setMaxAge(50000);
response.addCookie(myCookie);
</cfscript>

Any one have a clue how this could be done, and if it would be outside coldfusions cookie scope if it is done?



My website, or a bad habit?
BarSmart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top