• Advertisement
Sign in to follow this  

[.net] Storing page variables into cookies ...yammy!!

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi ! I am trying to store all page variables into cookies ...something like every page with its own cookie in C# ASP.NET.... Here's what i tried to do : I have an input box (id=Name) and i try to save the value into a cookie if this input box is not empty ...see below ....Now ...the thing i don't know is ...how do i reference data from cookie when i refresh my page.....? THX!

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="varCookies.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

         HttpCookie MyCookie = new HttpCookie("Name");
          MyCookie.Values["Name"] = Name.Text;
         //MyCookie.Expires = ;

		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<asp:TextBox id="Name" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 128px" runat="server"
			<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 32px; POSITION: absolute; TOP: 96px" runat="server"
				Width="312px" Height="24px">Enter your name :</asp:Label>
			<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 144px; POSITION: absolute; TOP: 192px" runat="server"
				Width="240px" Text="Submit"></asp:Button>

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement