Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for cookies
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00816484
Message ID:
00817606
Views:
19
Here's some javascript that I intend to add to my product, ASPvote, to check for cookies:
//-----------------------------------TESTING TO SEE IF COOKIES ARE ENABLED
	function SetCookie (name, value)   {
	    var time = 24*60*60*7 //one week
		var expDate = new Date()
		expDate.setTime (expDate.getTime() + time)
		document.cookie = name + "=" + escape (value) +  ";expires=" + expDate.toGMTString()
	}

	function GetCookie(name)   {
	    var result = null
	    var myCookie = " " + document.cookie + ";"
	    var srchName = " " + name + "="
	    var start = myCookie.indexOf(srchName)
	    var end;
	    if (start != -1){
		start += srchName.length
		end = myCookie.indexOf(";", start)
		result = unescape (myCookie.substring(start, end))
	    }
	    return result;
	}

	function test() {
	    tested = GetCookie('safecookie');
	    if (tested != null) {
		tested = 1;
	    }
	    else {
		tested = -1;
	    }
	    return tested;
	}

	SetCookie('safecookie','true');
	man = test();
//--------------------------------------------------ENDING THE COOKIE TEST

if (man>0) {
//----------do whatever since cookies are enabled ;
		  }
else {
	'You need to have cookies enabled';
		   }
>I have a form and an asp page that collect data and test for cookies being enabled.
>Even tho I've disabled cookies (and this is confirmed by visiting sites that require cookies, such as UT), somehow my code is behaving as if cookies are enabled and my code writes to the cookies and retrieves data back from the cookies...however I can't find any evidence of the cookie on my workstation or server.
>
>Any Ideas????
Previous
Reply
Map
View

Click here to load this message in the networking platform