cookies : how to write page_load to cookies
-
i am attempting to write the cookies for a landing page. i have used the following code to analyse the presence of cookies, but dont know how to write the cookie for the page loading. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Request.Cookies("Landing") Is Nothing Then 'if the name cookie does not exist ask user to enter name Response.Redirect("landing.aspx") Else 'if cookies already exist then show landing page Response.Redirect("tMN_index.aspx") End If this seems to work in terms of directing to the landing page.. just need the cookie help.... i basically want the landing page to appear if the cookie isnt present, and then the landing page to generate the cookie if not present. thank you
John Michael Kinsella kinsellajohn@hotmail.com
-
i am attempting to write the cookies for a landing page. i have used the following code to analyse the presence of cookies, but dont know how to write the cookie for the page loading. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Request.Cookies("Landing") Is Nothing Then 'if the name cookie does not exist ask user to enter name Response.Redirect("landing.aspx") Else 'if cookies already exist then show landing page Response.Redirect("tMN_index.aspx") End If this seems to work in terms of directing to the landing page.. just need the cookie help.... i basically want the landing page to appear if the cookie isnt present, and then the landing page to generate the cookie if not present. thank you
John Michael Kinsella kinsellajohn@hotmail.com
As I understand, you want to know how to create a new cookie. Below is a simple example how to do that. Depends on your needs, set appropriate properties of System.Web.HttpCookie object. Basically you simply add a new cookie object into Response.Cookies collection and that's all. Using Respose.Cookies class you can also remove or change any cookie your application creates. Dim cookie As System.Web.HttpCookie Dim cookieName As String Dim cookieValue As String cookie = New System.Web.HttpCookie(cookieName, cookieValue) Response.Cookies.Add(cookie)
-- Mariusz 'mAv' Wójcik master e-software engineer