|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
checking for enabled cookies?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("CookiesEnabled") = True 'On second page If Not AreCookiesEnabled() = True Then Response.Redirect("~\CookieError.aspx") End If Public Function AreCookiesEnabled() As Boolean On Error GoTo A If Session("CookiesEnabled") = True Then Return True End If A: Return False End Function 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/library/aa289495(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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Show quote
Hide quote
"Luke Zhang [MSFT]" <lukez***@online.microsoft.com> wrote in message The code and flow of the pages in site above looks like what I'm looking for news:AyTRDcjLHHA.2304@TK2MSFTNGHUB02.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/library/aa289495(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 my specific problem. Thanks (and to Michel also) Jeff Well i would modify the code to this
'On first page Session("CookiesEnabled") = True 'On second page If Not AreCookiesEnabled() Then Response.Redirect("~\CookieError.aspx") End If Public Function AreCookiesEnabled() As Boolean try If cbool(Session("CookiesEnabled")) Then Return True catch ex as exception return false end try End Function Show quoteHide quote "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("CookiesEnabled") = True > > > 'On second page > If Not AreCookiesEnabled() = True Then > Response.Redirect("~\CookieError.aspx") > End If > > Public Function AreCookiesEnabled() As Boolean > On Error GoTo A > If Session("CookiesEnabled") = True Then > Return True > End If > A: Return False > End Function > > > > -- > Posted via a free Usenet account from http://www.teranews.com > > You can also do this client side with javascript
see this code http://www.irt.org/script/1582.htm regards Michel Show quoteHide quote "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("CookiesEnabled") = True > > > 'On second page > If Not AreCookiesEnabled() = True Then > Response.Redirect("~\CookieError.aspx") > End If > > Public Function AreCookiesEnabled() As Boolean > On Error GoTo A > If Session("CookiesEnabled") = True Then > Return True > End If > A: Return False > End Function > > > > -- > Posted via a free Usenet account from http://www.teranews.com > > |
|||||||||||||||||||||||