473,698 Members | 2,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cookie test?

I have always used this in ASP to test if the client is accepting cookies:

<%@language="VB Script"%>
<%
Session ("nc") = 1
If Len(Session("nc ")) = 0 Then
'Cookies Off
Else
'Cookies On
End If
%>

But I only ever tested it in Microsoft Internet Explorer 6 though not sure. Anyway with Microsoft Internet Explorer 5.5 SP2 Len(Session("nc ")) <> 0 always whether cookies are on or off. Can anyone suggest a better cookie test that will work in most browsers? Thanks.

--
George Hester
_______________ _______________ ____
Jul 19 '05
12 2497
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
Maintaining the session state on the current page or the next page or
any page,


The server only "knows" it cannot maintain the session if it does not get a
session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11
OK based on that I have another idea then. Thanks. But you know I have been doing it this way for a very long time. I have Windows 2000 Professional set up and I am going to go try it over there. It has SP4 in it.

--
George Hester
_______________ _______________ ____
"Evertjan." <ex************ **@interxnl.net > wrote in message news:Xn******** ************@19 4.109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
Maintaining the session state on the current page or the next page or
any page,


The server only "knows" it cannot maintain the session if it does not get a
session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #12
All that time I been using that method. But it looks as though I must have
been living in timbuktu because it's not working over here either. You know
I tested over this and over and over till it worked. Because I also detect
when scripting is off in the same set of code. Now all that happens is the
scripting test. The cookie test just seems to have died. I hate it when
that happens. Thanks for putting up with me and the explanations.

--
George Hester
_______________ _______________ ___
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.29...
George Hester wrote on 30 jan 2004 in
microsoft.publi c.inetserver.as p.general:
Maintaining the session state on the current page or the next page or
any page,
The server only "knows" it cannot maintain the session if it does not get

a session-id cookie value back, that the server delivered.

So the server is unaware of that possibility till it is asks for a second
page with should have that cookie.

So it must assume the second request is from a new session and any session
variable to be tested returns an empty string.

So those pages are not sessionless, they are all the first page of a new
session.

So the session variables set on such page are valid on that page only.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
11311
by: Phil Powell | last post by:
Fourth attempt.. it fails now in login, I check by printing $_COOKIE and there is no value there! Guys, what on earth do I do about this???? Here is the code that sets the cookie: if ($hasLoggedIn && ($row = mysql_fetch_row($query))) { setcookie('nordicnet_registration', $row, 0, '/'); @mysql_free_result($query);
3
2867
by: Stijn Goris | last post by:
hi all, Trying to get those cookies to work but they wont... Doing this. Have a page login.php wich tests the user and pass. If they are correct a cookie is set with one variable like this: setcookie ("cookieUser", $user); then the browser is sent with header("Location: spelersPage.php"); to another page. I there try to read the cookievariable cookieUser on the spelersPage.php
3
1688
by: Agent M | last post by:
Hi there New to PHP. Im trying to set a cookie but for some reason it wont work. The code is inside a Submit button and happens after I have read the MySQL database and succesfully retrieved the record. For some reason the cookie is not created. Here is the code setcookie("firstname",$firstname,time() + (7 * 86400));
6
2193
by: Ajay | last post by:
hi! i am printing a simple cookie, but instead of printing um=name:blah&access:admin&exp:2312390.909 its printing um="name:blah&access:admin&exp:2312390.909" why the quotes?
4
5290
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a cookie. Here is the code I have now. In the header, I have the following: <SCRIPT language="JavaScript"> var cookieStatus; if (document.cookie.length > 0) { cookieStatus = 'Cookie exists with value ' + document.cookie; } else {
12
17998
by: chrism | last post by:
Hello, I have a pop-up window that I would like to appear in front of the browser home page when a user opens IE. Problem is, I'd like it to never appear again if the user navigates back to the home page during their time using the browser. However, if the user closes the browser, then reopens, the pop-up should appear again. (you may have guessed that this will be used for public access pc's.) I want to try as best I can to catch...
5
3312
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the document.cookie variable combine all cookie key=value pairs? All of the examples I've seen discuss referencing a specific cookie. I don't see how this is done. Cookies are usually named by the domain. If I want to reference a specific cookie, do I...
1
2218
by: Mike | last post by:
Hello, I can't find any javascript that reads and writes cookies with keys, so that it is compatible with ASP (I want to read and write cookies from both javascript and ASP) for example in ASP: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith"
1
2003
by: ticmanis | last post by:
Hello, I'm having trouble getting MSIE 6.0 (running on XP SP2) to accept a cookie which works fine in both Firefox and wget. The web server is Boa 0.94.13 (a small embedded server) using PHP 4.3.10 for CGI. Even with the lowest security settings in MSIE there is no cookie acceptance, and no "Cookie:" HTTP header is being sent back by MSIE. This is the php code for a fairly minimal testcase:
3
2595
by: WayneH | last post by:
Hi - I'm trying to use javascript to determine if a user's browser has cookies enabled or not. To test: copy this code into a file with a 'html' extension, and load it into your IE browser directly, through a local web server and through a remote web server. By turning cookies on/off in your browser, running the file, then clicking the 'test1' or 'test2' buttons, the displayed text should accurately inform you if your cookies are On or...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.