473,799 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As Object, ByVal e As EventArgs)
Dim user As String = Current.User.Id entity.Name
Dim roleCookieName As String = user & "-Roles"
Dim rolesList As String = Response.Cookie s(roleCookieNam e ).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.Cookie s(roleCookieNam e ).Value = rolesList
Response.Cookie s(roleCookieNam e ).Expires =
DateTime.Now.Ad dHours(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.N ame()
Dim roleCookieName As String = userId & "-Roles"
Dim roles As String = Response.Cookie s(roleCookieNam e ).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 1179
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
3378
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 on the testing server but that didn't seem to make any difference. One difference I noticed is that on the dev server, the session cookie is modified on EVERY page load. On the testing server the cookie gets created alright but it doesn't seem...
4
1381
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 to/from work. I don't have room on the PDA for all the associated advertising stuff these sites have, so I filter out all but the important text. It's worked a treat until recently when 1 of the sites I read upgraded. When I browsed to it using...
9
1379
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 can be accessed by other JS scripts in the same page? Thanks, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East...
3
11128
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 behind and don't use a domain then I can not change or remove that cookie's value on the client. If I subsequently create the cookie again in the codebehind then I actually end up with TWO cookies with the same name in the response. The cookie...
5
7268
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 setting a cookie for a path like "/somepath", and trying to read it on a path like "/SomePath". This was coming back as a non-set cookie. So now I know what the problem is, I'm stuck with how to get around it. In an ideal world, users would only...
17
4184
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 hosted at two.com If I view the frameset from one.com in Firefox, all works well with the content from two.com. But if trying to view this using IE (with standard security settings), the cookie set by two.com is not accessible.
29
3014
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 switch/case to take action based on that value in the cookie. I want to set the cookie manually, so I don't need setcookie(). I see that in PHP it stores the cookie in memory. Is there a way to have PHP just read a cookie from the desktop machine?...
2
2143
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 work consistently. Sometimes we are getting the latest value set from server in client script, sometimes were are getting a wrong (previously set old) value. In other words, the values in client and server is not in sync. Can anybody suggest...
10
1699
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 using Request.Cookies.Value.ToString(). I can read the same cookie in ASP code. If I say Request.Cookies("CookieName") in ASP that works fine..
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.