473,624 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking for enabled cookies?


I have a vb.net application (2005) requiring session variables and want to
test to make certain that the user's cookies are enabled.

I can set a test session variable on one page and attempt to read it on the
next with the code below in order to determine if the user has their
browser's cookies enabled, but is there a good way to do this on the
first/default page without a redirect to another page that will actually do
the test?

Thanks
Jeff
'On first page
Session("Cookie sEnabled") = True
'On second page
If Not AreCookiesEnabl ed() = True Then
Response.Redire ct("~\CookieErr or.aspx")
End If

Public Function AreCookiesEnabl ed() As Boolean
On Error GoTo A
If Session("Cookie sEnabled") = True Then
Return True
End If
A: Return False
End Function

--
Posted via a free Usenet account from http://www.teranews.com

Dec 31 '06 #1
4 4041
Hello Jeff,

Your way is already the regular way we check if a client supports cookies.
This is also discussed in this article:

Basics of Cookies in ASP.NET
http://msdn2.microsoft.com/en-us/lib...95(VS.71).aspx

You may check the section of "Checking Whether a Browser Accepts Cookies",
it uses a similiar way. Also there is a lot about cookies in this article,
hope this help.

Sincerely,

Luke Zhang

Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 2 '07 #2
Well i would modify the code to this

'On first page
Session("Cookie sEnabled") = True
'On second page
If Not AreCookiesEnabl ed() Then
Response.Redire ct("~\CookieErr or.aspx")
End If

Public Function AreCookiesEnabl ed() As Boolean
try
If cbool(Session(" CookiesEnabled" )) Then Return True
catch ex as exception
return false
end try
End Function


"Jeff" wrote:
>
I have a vb.net application (2005) requiring session variables and want to
test to make certain that the user's cookies are enabled.

I can set a test session variable on one page and attempt to read it on the
next with the code below in order to determine if the user has their
browser's cookies enabled, but is there a good way to do this on the
first/default page without a redirect to another page that will actually do
the test?

Thanks
Jeff
'On first page
Session("Cookie sEnabled") = True
'On second page
If Not AreCookiesEnabl ed() = True Then
Response.Redire ct("~\CookieErr or.aspx")
End If

Public Function AreCookiesEnabl ed() As Boolean
On Error GoTo A
If Session("Cookie sEnabled") = True Then
Return True
End If
A: Return False
End Function

--
Posted via a free Usenet account from http://www.teranews.com

Jan 2 '07 #3
You can also do this client side with javascript

see this code

http://www.irt.org/script/1582.htm

regards

Michel
"Jeff" wrote:
>
I have a vb.net application (2005) requiring session variables and want to
test to make certain that the user's cookies are enabled.

I can set a test session variable on one page and attempt to read it on the
next with the code below in order to determine if the user has their
browser's cookies enabled, but is there a good way to do this on the
first/default page without a redirect to another page that will actually do
the test?

Thanks
Jeff
'On first page
Session("Cookie sEnabled") = True
'On second page
If Not AreCookiesEnabl ed() = True Then
Response.Redire ct("~\CookieErr or.aspx")
End If

Public Function AreCookiesEnabl ed() As Boolean
On Error GoTo A
If Session("Cookie sEnabled") = True Then
Return True
End If
A: Return False
End Function

--
Posted via a free Usenet account from http://www.teranews.com

Jan 2 '07 #4

"Luke Zhang [MSFT]" <lu******@onlin e.microsoft.com wrote in message
news:Ay******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hello Jeff,

Your way is already the regular way we check if a client supports cookies.
This is also discussed in this article:

Basics of Cookies in ASP.NET
http://msdn2.microsoft.com/en-us/lib...95(VS.71).aspx

You may check the section of "Checking Whether a Browser Accepts Cookies",
it uses a similiar way. Also there is a lot about cookies in this article,
hope this help.

Sincerely,

Luke Zhang
The code and flow of the pages in site above looks like what I'm looking for
my specific problem.

Thanks (and to Michel also)

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Jan 3 '07 #5

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

Similar topics

7
5563
by: | last post by:
It is possible to check via ASP whether cookies are enabled for a person's web browser and based on this check send him to another page which does not support cookies (ie login?)? Thanks Jason
0
333
by: Lucifer | last post by:
Hi I have some code for checking for cookies, that sets a cookie on page1 and checks for it on page2. and its based on the code by MS: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.asp under section: 'Checking Whether a Browser Accepts Cookies' This code works great, when its in my development enviroment.
9
7850
by: Agoston Bejo | last post by:
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
0
1244
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 privacy setting to a High level so as to block all cookies, the code always returns that the...
0
1266
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 privacy setting to a High level so as to block all cookies, the code always returns that the...
6
2713
by: NWx | last post by:
Hi, How can I detect is cookies are enabled or not in client browser? Thanks?
2
1094
by: Ben Amada | last post by:
I know to determine if cookies are enabled or not, you have to try to create a cookie then try to read it back. I know one method is to redirect the user to a 2nd page which creates the cookie, then the 2nd page redirects the user back to the 1st page which tries to read the cookie. The other method I thought of and am wondering if this is reliable or not, is to create a cookie when IsPostBack = False, then have the user click a Submit...
4
1315
Bob Ross
by: Bob Ross | last post by:
I'm sure I know the answer to this already but.... Does anyone know a good way of checking if cookies are enabled on a browser? I currently have If Request.QueryString("Trying") = "" Then Session.Add("SessionCookie", "ON") Response.Redirect(Request.Path & "?Trying=ON", True) Else If Session("SessionCookie") = "" Then
3
7777
by: =?Utf-8?B?Qkw=?= | last post by:
if (Request.Browser.Cookies) { // Cookies supported } else { // Web browser not supports cookies }
0
8631
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8490
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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
4084
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
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
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
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.