473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Cookie isn't being read

Hi,
I am having a problem reading a cookie that I can see is being
created. I create the cookie in my global.aspx.vb page like so:

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim user As String = Current.User.Identity.Name
Dim roleCookieName As String = user & "-Roles"
Dim rolesList As String = Response.Cookies(roleCookieName ).Value

'Only try to create the cookie if it is not already created.
If (rolesList Is Nothing) Then
Dim rolesArray As String() = Common.GetRoles()
If (Not (rolesArray Is Nothing)) Then
rolesList = rolesList.Join(",", rolesArray)
Response.Cookies(roleCookieName ).Value = rolesList
Response.Cookies(roleCookieName ).Expires =
DateTime.Now.AddHours(2)
Else
Throw New HttpException("An error occurred determining
what roles exist for user: " & user)
End If
End If
End Sub

I then use this in the page load method of my page and within that
page load, I can retrieve this cookie just fine like so:

Dim userId as string = User.Identity.Name()
Dim roleCookieName As String = userId & "-Roles"
Dim roles As String = Response.Cookies(roleCookieName ).Value

The problem is that every 30 minutes we do a refresh of this page. So
when it does that, it goes back up to the Session_Start method above,
and tries to read the cookie. For some reason, it is returning
Nothing when it tries to read that cookie, even though I have gone out
and looked and the cookie exists. All my information that I write to
this cookie is not accessible in my GetRoles method the second time
around because it relies on session information that I lose after 30
minutes (thus why we are trying to write to a cookie).

Is there some reason, it can read the cookie the first time but cannot
read the cookie upon a refresh?

Apr 30 '07 #1
1 1152
Never mind, I believe the issue was that I was using Response to try
and read it instead of Request.
Apr 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Henry Hartley | last post by:
I've got a PHP system working on a development server (Windows 2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on the testing server (same except PHP 4.2.3). I upgraded the PHP...
4
by: Ian Mooney | last post by:
I'm using the HttpWebRequest and HttpWebResponse components to automatically scrape content from various internet news sites to store on my iPaq PDA which I later read off-line while commuting...
9
by: Don | last post by:
I understand that when I send a cookie in a client-side page containing JS, it isn't actually "set" until the next page is loaded. Is there some way to "set" it within the same html/JS page so it...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
5
by: Alan Silver | last post by:
Hello, I've just spent ages debugging some cookie code that wasn't working, and have finally discovered that the code *was* working, but that the path used by cookies is case-sensitive. I was...
17
by: Bruno | last post by:
I have a feature that is hosted on a different domain from the primary one in a frame, and need to retain values in a cookie. example: A web page at one.com contains a frame which has a page...
29
by: Jerim79 | last post by:
I did try to find the answer to this before posting, so this isn't a knee jerk reaction. What I am trying to accomplish is to have a script that opens a cookie, reads a value, and then use a...
2
by: arijitdas | last post by:
Hi, We have an ASP.NET 2.0 web application where we want to share few user specific data between server and client side code using cookie. We are seeing a very strange behavior that it does not...
10
by: icanhelp33 | last post by:
I have a C# utility that runs in ASP website. When user logs in the ASP code writes the cookie using Response.Cookie. I try to read the same cookie in C#. I am unable to read it in C# code. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.