• 0

setting a cookie on the client side


Question

I'm trying to get this to work in Internet Explorer, but so far no luck. Only seem to be able to get it to work in Mozilla for now. Here is a reference:

http://office.wendellhull.com/matdb/defaul...rade_name_id=35

The dropdown box next to "Unit" is what we are looking at. What should happen, is the user selects what unit they want, and on their side a cookie is set and the page is redrawn. The one that the user selects should still be selected. This works fine in Mozilla, but no luck in Internet Explorer. Any ideas? Does IE not like cookies to be set by the client side and read on the server side?

Here is my java script:

function SetCookie (name,value,expires,domain) {
var Str;
 Str=name + "= " + value + "; expires=" +  expires.toGMTString() + ";domain="+domain;
 document.cookie = Str;
}

function SetUnit (unittype, selSelectObject, theurl) {
	var expdate = new Date ();
  expdate.setTime (expdate.getTime() + (10 * 365 *   24 * 60 * 60 * 1000)); // 10 years from now
	SetCookie(unittype, selSelectObject.options[selSelectObject.selectedIndex].value, expdate, 'office.wendellhull.com');
	location.href = theurl;
}

I'm using ASP to try to read the cookie from the server side. Here is the code that draws the temperature unit drop down box:

Sub draw_temp_dropdown()
	Dim currentcookie
	currentcookie = request.cookies("temperature")
	Response.Write "<select name=""temp_dropdown"" onChange=""SetUnit('temperature', this, 'default.asp?" & set_querystring("none") & "')"">"
	Response.Write "<option"
	If currentcookie = "C" Then
  Response.Write " SELECTED"
	End If
	Response.Write ">C</option>"
	Response.Write "<option"
	If currentcookie = "F" Then
  Response.Write " SELECTED"
	End If
	Response.Write ">F</option>"
	Response.Write "<option"
	If currentcookie = "K" Then
  Response.Write " SELECTED"
	End If
	Response.Write ">K</option>"
	Response.Write "</select>"
End Sub

I'll probably have to rewrite to just do all server side cookie sets, but I'd rather not.

Thanks for any help!

-Nic

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.