473,563 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect if cookies are enabled?

Hi,
I searched around everywhere on the net, but could not find a simple example
of detecting if cookies are enabled - on server side, and without moving
from one page to another.
This should be a very basic functionality, so I am reluctant to believe that
there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston
Jul 22 '05 #1
9 7845
AFAIK no. You have to test this client side (it could be on the same page
depending on what exactly annoys you with client side methods).

Patrice

--

"Agoston Bejo" <gu***@freemail .hu> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,
I searched around everywhere on the net, but could not find a simple example of detecting if cookies are enabled - on server side, and without moving
from one page to another.
This should be a very basic functionality, so I am reluctant to believe that there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston

Jul 22 '05 #2
"Agoston Bejo" <gu***@freemail .hu> wrote in message
news:#H******** ******@TK2MSFTN GP10.phx.gbl...
Hi,
I searched around everywhere on the net, but could not find a simple example of detecting if cookies are enabled - on server side, and without moving
from one page to another.
This should be a very basic functionality, so I am reluctant to believe that there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston


"... detecting if cookies are enabled - on server side ..."

Are you asking how to detect if client-side cookies are enabled via
server-side ASP?
"Response.Cooki es" is defined as "A collection containing the values of all
the cookies that will be sent back to the client in the current response.".

"Request.Cookie s" is defined as A collection of the values of all the
cookies sent from the user's system along with their request."

Thus, I thought that this would work:

Response.Cookie s("aCookie") = "Hello World"
Response.Write "Are client-side cookies enabled? = " & (Not
IsEmpty(Request .Cookies("aCook ie")))

But it returned "True" even when Cookies were disabled.
Jul 22 '05 #3
McKirahan wrote on 10 feb 2005 in
microsoft.publi c.inetserver.as p.general:
detecting if cookies are enabled - on server side,
and without moving from one page to another.
But that is a silly expectation.
Thus, I thought that this would work:

Response.Cookie s("aCookie") = "Hello World"
Response.Write "Are client-side cookies enabled? = " & (Not
IsEmpty(Request .Cookies("aCook ie")))

But it returned "True" even when Cookies were disabled.


How do you expect the server knowing anything about the client,
without contacting the client?

You will have to resort to something like this:

1.asp:

<%
Response.Cookie s("aCookie") = "Hello World"
Response.redire ct "2.asp"
%>

2.asp:

<%
If Session("aCooki e") = "Hello World" Then
Response.Write "Cookies Enabled"
Else
Response.Write "Cookies Disabled"
End If
%>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #4
The problem is that it works as a request/response pairs.

The client sends a request and you respond to this request. If you write
down cookies to the response, it will make them visible in the *next*
request, not in the request you respond to.
You'll have to use something similar to what Evertjan shows (there is a
typo, this Cookies not Session).

You could do it on the same page if this is really a problem with some query
string to know at which step you are...

Patrice

--

"McKirahan" <Ne**@McKirahan .com> a écrit dans le message de
news:bO******** ************@co mcast.com...
"Agoston Bejo" <gu***@freemail .hu> wrote in message
news:#H******** ******@TK2MSFTN GP10.phx.gbl...
Hi,
I searched around everywhere on the net, but could not find a simple example
of detecting if cookies are enabled - on server side, and without moving
from one page to another.
This should be a very basic functionality, so I am reluctant to believe

that
there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston


"... detecting if cookies are enabled - on server side ..."

Are you asking how to detect if client-side cookies are enabled via
server-side ASP?
"Response.Cooki es" is defined as "A collection containing the values of

all the cookies that will be sent back to the client in the current response.".
"Request.Cookie s" is defined as A collection of the values of all the
cookies sent from the user's system along with their request."

Thus, I thought that this would work:

Response.Cookie s("aCookie") = "Hello World"
Response.Write "Are client-side cookies enabled? = " & (Not
IsEmpty(Request .Cookies("aCook ie")))

But it returned "True" even when Cookies were disabled.

Jul 22 '05 #5
[...]
detecting if cookies are enabled - on server side,
and without moving from one page to another.
But that is a silly expectation.

[...] How do you expect the server knowing anything about the client,
without contacting the client?


Request.ServerV ariables("HTTP_ USER_AGENT")
By using this, you definitely get some information about the client on
server side. So I don't think that expectation is so silly. I accept that
about cookies you cannot get information this way, however.

Thanks anyway!

Jul 22 '05 #6
Agoston Bejo wrote on 12 feb 2005 in
microsoft.publi c.inetserver.as p.general:
[...]
> detecting if cookies are enabled - on server side,
> and without moving from one page to another.


But that is a silly expectation.

[...]
How do you expect the server knowing anything about the client,
without contacting the client?


Request.ServerV ariables("HTTP_ USER_AGENT")
By using this, you definitely get some information about the client on
server side. So I don't think that expectation is so silly. I accept
that about cookies you cannot get information this way, however.

Thanks anyway!


The HTTP_USER_AGENT value is sent with the request,
as are available cookie values tagged to the server domain.

So you could test for those cookie values, but if absent,
the difference between no cookies available and cookies switched off
cannot be detected without testing for it on the client as shown.

Yes, the powers that defined the cookie mechanism could have defined and
required a cookies-switched-off flag in the page request sent by the
browser, but they did not.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #7

What annoys me is that first I have to detect if JavaScript is enabled in
order to be able to test whether cookies are enabled.

Agoston

"Patrice" <no****@nowhere .com> wrote in message
news:eX******** ******@TK2MSFTN GP10.phx.gbl...
AFAIK no. You have to test this client side (it could be on the same page
depending on what exactly annoys you with client side methods).

Patrice

--

"Agoston Bejo" <gu***@freemail .hu> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,
I searched around everywhere on the net, but could not find a simple

example
of detecting if cookies are enabled - on server side, and without moving
from one page to another.
This should be a very basic functionality, so I am reluctant to believe

that
there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston


Jul 22 '05 #8
You don't need JavaScript. See Evertjan response in this thread...

Patrice
--

"Agoston Bejo" <gu***@freemail .hu> a écrit dans le message de
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .

What annoys me is that first I have to detect if JavaScript is enabled in
order to be able to test whether cookies are enabled.

Agoston

"Patrice" <no****@nowhere .com> wrote in message
news:eX******** ******@TK2MSFTN GP10.phx.gbl...
AFAIK no. You have to test this client side (it could be on the same page depending on what exactly annoys you with client side methods).

Patrice

--

"Agoston Bejo" <gu***@freemail .hu> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,
I searched around everywhere on the net, but could not find a simple

example
of detecting if cookies are enabled - on server side, and without moving from one page to another.
This should be a very basic functionality, so I am reluctant to
believe that
there's no way to simply test it in a server-side script.
Anyone?

Thx,
Agoston



Jul 22 '05 #9
Evertjan. (before drinking his coffee) wrote:
<snipped>
You will have to resort to something like this:
1.asp:
<%
Response.Cookie s("aCookie") = "Hello World"
Response.redire ct "2.asp"
%>

2.asp:
<%
If Session("aCooki e") = "Hello World" Then ^^^^^^^^^^^^^^^ ^^^
Request.Cookies ("aCookie") Response.Write "Cookies Enabled"
Else
Response.Write "Cookies Disabled"
End If
%>

Jul 22 '05 #10

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

Similar topics

0
1243
by: Sri. | last post by:
Hi I am trying to figure out how to test whether my browser cookies are enabled. I used the code from the following page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.as Basically, it tells me to create a cookie and test the cookie from another page. However, in IE 6.0, if I set my...
0
1264
by: Sri | last post by:
Hi I am trying to figure out how to test whether my browser cookies are enabled. I used the code from the following page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.as Basically, it tells me to create a cookie and test the cookie from another page. However, in IE 6.0, if I set my...
6
2711
by: NWx | last post by:
Hi, How can I detect is cookies are enabled or not in client browser? Thanks?
1
2829
by: oreng | last post by:
Hey all, I have some problems detecting whether the client's browser javascript is enabled at the server side. While Request.Browser.JavaScript only check if the browser enable java script (and so on with Request.Browser.Cookies). I saw some server controls that register a startup script on the page_load and then perform a postback and...
2
1352
by: Tee | last post by:
Hi, How can we easily detect cookies is enabled? Thanks
1
2476
by: FishKeeper | last post by:
I'm trying to write JavaScript code to test whether cookies are enabled by writing a cookie and then reading its value. My code works fine in Firefox, but it's not working in Internet Explorer 6. I have my privacy settings set to block all cookies, but my JavaScript can read and write cookies. Does this setting just block server cookies? ...
3
1959
by: Victor | last post by:
I was thinking about an easy to determine if cookies are set or not in ASP. I began thinking about how the Session ID is dependent upon a cookie - right? Well, I disabled cookies in Firefox and then loaded a webpage that displayed Session.SessionID. Viola, I got one! And then, I reloaded the page. And then, I noticed that the SessionID...
24
2412
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How can I see in javascript if a web browser accepts cookies? ----------------------------------------------------------------------- Writing a cookie, reading it back and checking if it's the same. http://www.w3schools.com/js/js_cookies.asp Additional...
1
1960
stepterr
by: stepterr | last post by:
Hi All, Does anyone know if it is possible to detect if a user has SSL enabled in their browser? I have a login page that is https but if the user does not have SSL enabled it of course just gives them a page cannot be displayed message. What I would like to do is verify that they have it enabled, if they do not, then send them to another page...
0
7664
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...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
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...
0
5213
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...
0
3642
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
923
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...

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.