Information & support > Knowledge base > Developer >Laatst bijgewerkt opMarch 12, 2021Server side usage – VBIf your website is setting cookies server side, you can determine what type of cookies you are allowed to set by checking the users current consent state through standard cookie handling.VBImports System.Web.Script.Serialization ... Dim CurrentUserConsent As HttpCookie = Request.Cookies("CookieConsent") If CurrentUserConsent IsNot Nothing Then Select Case CurrentUserConsent.Value Case "0" REM The user has not accepted cookies - set strictly necessary cookies only Exit Select Case "-1" REM The user is not within a region that requires consent - all cookies are accepted Exit Select Case Else REM The user has accepted one or more type of cookies REM Read current user consent in encoded JavaScript format Dim CookieConsentSerializer As New JavaScriptSerializer() Dim CookieConsent As dynamic = CookieConsentSerializer.Deserialize(Of Object)(HttpUtility.UrlDecode(CurrentUserConsent.Value)) If CookieConsent("preferences") Then REM Current user accepts preference cookies Else REM Current user does NOT accept preference cookies End If If CookieConsent("statistics") Then REM Current user accepts statistics cookies Else REM Current user does NOT accept statistics cookies End If If CookieConsent("marketing") Then REM Current user accepts marketing cookies Else REM Current user does NOT accept marketing cookies End If End Select Else REM The user has not accepted cookies - set strictly necessary cookies only End If14 day free trial CookiebotCookie scanner, cookie banner, cookie declaration and cookie consent in one solution.Use cookies on your website compliant with GDPR, ePrivacy and cookie legislationCookie management completely automatedCookie banner based on your corporate identityAutomatic composed cookie declaration, always up to dateStart 14 day free trialThe Cookiebot solution runs on 2,3 million websites, manages 7 billion monthly User Consents and supports 47+ languages.Previous Facebook Twitter LinkedIn E-mailNext
Laatst bijgewerkt opMarch 12, 2021Server side usage – VBIf your website is setting cookies server side, you can determine what type of cookies you are allowed to set by checking the users current consent state through standard cookie handling.VBImports System.Web.Script.Serialization ... Dim CurrentUserConsent As HttpCookie = Request.Cookies("CookieConsent") If CurrentUserConsent IsNot Nothing Then Select Case CurrentUserConsent.Value Case "0" REM The user has not accepted cookies - set strictly necessary cookies only Exit Select Case "-1" REM The user is not within a region that requires consent - all cookies are accepted Exit Select Case Else REM The user has accepted one or more type of cookies REM Read current user consent in encoded JavaScript format Dim CookieConsentSerializer As New JavaScriptSerializer() Dim CookieConsent As dynamic = CookieConsentSerializer.Deserialize(Of Object)(HttpUtility.UrlDecode(CurrentUserConsent.Value)) If CookieConsent("preferences") Then REM Current user accepts preference cookies Else REM Current user does NOT accept preference cookies End If If CookieConsent("statistics") Then REM Current user accepts statistics cookies Else REM Current user does NOT accept statistics cookies End If If CookieConsent("marketing") Then REM Current user accepts marketing cookies Else REM Current user does NOT accept marketing cookies End If End Select Else REM The user has not accepted cookies - set strictly necessary cookies only End If