Solved

Can a .NET page read a cookie written by an html page?

Posted on 2016-08-20
3
50 Views
Last Modified: 2016-08-20
I am writing a cookie via javascript from within a basic HTML page, to indicate that the user is logged in.
There is another page on the site that is written in ASP.NET, which needs to know whether the user is logged in.
Is it possible for an ASP.NET page to read a cookie written by an HTML page? Or can .NET pages only read cookies written by other .NET pages?
0
Comment
Question by:rascal
3 Comments
 
LVL 9

Accepted Solution

by:
bas2754 earned 250 total points
ID: 41763841
Old post from here outlines the steps:
----------------
http://forums.asp.net/t/1250217.aspx?cookie+writing+in+javascript+and+reading+in+asp+net

Summary of the answer from that page:
-----------------------
            Dim UserResolution As String
            If Request.Cookies("Screen") IsNot Nothing Then
                Dim TheCookie As HttpCookie = Request.Cookies("Screen")
                UserResolution = Server.HtmlEncode(TheCookie.Value)
            Else
                UserResolution = "NA"
            End If

Open in new window


Basically you just substitue the name of your cookie for the "Screen" variable written above and it should work for you.  Read through the page for more info, but I do know it works as I have done it as well, I just don't have access to the code right now to give you the examples I have done.
0
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 125 total points
ID: 41763855
A qualified yes.. getting the details right is the hard part.
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 125 total points
ID: 41763878
In cookies, the domain name must be an exact text match.  'www.domain.com' is Not the same as 'domain.com' in cookies.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now