Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home CSharp ASP.NET Cookie Domains HTTP HTTPS

ASP.NET Cookie Domains HTTP HTTPS

In order to preserve cookies across primary domain and its sub domains with or without www and between http and https, you can check out a piece of asp.net written in C# code below:

1. Writing Cookie

Example below will write a cookie “your_cookie_name ” with value “your cookie value” and set the cookie’s domain property to yourdomain.com:

string cookie_str = "your cookie value";
Response.Cookies["your_cookie_name"].Value = cookie_str;
Response.Cookies["your_cookie_name"].Domain = "yourdomain.com";

string cookie_str = "your cookie value"; Response.Cookies["your_cookie_name"].Value = cookie_str; Response.Cookies["your_cookie_name"].Domain = "yourdomain.com";

2. Reading Cookie

Response.Write("Your cookie has been written with value: " + HttpContext.Current.Request.Cookies["your_cookie_name"].Value.ToString());

Response.Write("Your cookie has been written with value: " + HttpContext.Current.Request.Cookies["your_cookie_name"].Value.ToString());

The cookie will then be available to the primary domain (yourdomain.com) as well as to all its sub domains such as: subdomain1.yourdomain.com, subdomain2.yourdomain.com, etc.

It’s also available when you try to access through HTTP or HTTPS with or without www such as: https://yourdomain.com or https://www.yourdomain.com

Mar 27, 2012Hoan Huynh
Remove/Delete your saved passwords in IE, Firefox, Google ChromeSetup Free SSL Certificate For Testing On Development Environment In Windows IIS 7
You Might Also Like:
  • JavaScript Detect Protocol (HTTP/ HTTPS) To Load Or Handle Accordingly
  • HTTP/ HTTPS Document, CGI-BIN And Access/ Error Logs On cPanel, Plesk And VirtualMin
  • Example Of crossdomain.xml – Cross Domain Policy File
  • ASP.NET Web Request POST/GET HTTPS Ignore Certificate Validation
  • PHP CURL Post To HTTPS Website
  • How To Track Website With Multiple Google Analytisc Accounts
  • ASP.NET Web Request Post/Get HTTP Example
  • Setup Free SSL Certificate For Testing On Development Environment In Windows IIS 7
  • Clear Web History, Cookies And Websites Data In Safari iPhone 4S
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago CSharpASP.NET, Cookie, HTTP, HTTPS, Request, Response493
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,554 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,892 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,745 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,069 views
C# Read Json From URL And Parse/Deserialize Json
11,802 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development