473,385 Members | 1,606 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,385 software developers and data experts.

Cookie not set fast enough

I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise
Nov 19 '05 #1
6 1514
Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise


Huh? I dont think that's possible. If it's linearly executed code its
not possible. Are you sure there isn't a potential issue elsewhere?
Perhaps cookies aren't allowed, not set properly, not called properly, etc?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #2
How are you writing the cookie? Could you provide some code?

Clint Hill
H3O Software
http://www.h3osoftware.com

Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise

Nov 19 '05 #3
I am guessing you have a user control on the same page as the button, and
you are looking for this in the user control's Load event? In which case,
the button's Click event is going to run after the Load event of the user
control (and the page this is all on for that matter).

You need to restructure the way your page communicates with the user control
and when you are pulling information out.

"Denise" <De****@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have an application that sets a cookie through a class. I set it in a
push
button event on a postback. When the page reloads, a user control checks
the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can
you
offer any solution?

Thanks,
Denise

Nov 19 '05 #4
It is happening - but not all the time. If I step through the code, it works
as expected. It works fine 80% of the time, but there are other times when
it pulls the prior cookie and reloads the wrong row.

private void NewButon_Click(...)
{
HttpCookie Cookie = new HttpCookie("CaseId", 0);
HttpContext Current.Response.Cookies.Add(Cookie);

LoadData();
}

private void LoadData()
{
HttpCookie Cookie = HttpContext.Current.Request.Cookies["CaseId"];
///Sometimes Cookie is equal to the prior cookie set !!!!
}

Actually, I was setting the cookies in a separate class using the
HTTPContext. When I tried pasting it directly into my code, I was using
Response.Cookies, but both seemed not to work well.

"Curt_C [MVP]" wrote:
Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise


Huh? I dont think that's possible. If it's linearly executed code its
not possible. Are you sure there isn't a potential issue elsewhere?
Perhaps cookies aren't allowed, not set properly, not called properly, etc?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

Nov 19 '05 #5
See above post

"Clint Hill" wrote:
How are you writing the cookie? Could you provide some code?

Clint Hill
H3O Software
http://www.h3osoftware.com

Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise

Nov 19 '05 #6
Yes, that is happening as well...I have one case where the user control is
loading before the cookie has been set, but that is not the problem I am
having. See above post.

"Marina" wrote:
I am guessing you have a user control on the same page as the button, and
you are looking for this in the user control's Load event? In which case,
the button's Click event is going to run after the Load event of the user
control (and the page this is all on for that matter).

You need to restructure the way your page communicates with the user control
and when you are pulling information out.

"Denise" <De****@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have an application that sets a cookie through a class. I set it in a
push
button event on a postback. When the page reloads, a user control checks
the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can
you
offer any solution?

Thanks,
Denise


Nov 19 '05 #7

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

Similar topics

16
by: Jochen Daum | last post by:
Hi! I have a function in a lot of pages, which redirects to a new page, if a form has been submitted: if (!(defined("DEBUG_INSERT") && DEBUG_INSERT) && !(defined("DEBUG_UPDATE") &&...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
14
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. ...
2
by: George Durzi | last post by:
When you call FormsAuthentication.SignOut(), is the FormsAuthentication cookie supposed to be destroyed automatically? I'm creating my FormsAuthentication cookie by doing: HttpCookie oCookie =...
3
by: Ben | last post by:
I'm having problems with cookies from asp.net to asp back to asp.net. It seems like I can set a cookie in asp.net fine, and alter it at will, as soon as asp touches it, asp.net won't have...
4
by: gl | last post by:
I'm currently making a web app that stores a user id in a cookie, and builds user information off of that in the differnt pages of the site. The cookie is created on login, and is separate from the...
6
by: Victor | last post by:
Hi everybody, could anybody help me with the following problem : I need to set a cookie containing a Russian character string as the value, using the construct "document.cookie = ...". The...
2
by: Sean | last post by:
I am trying to read a cookie I set but I am not sure if I really set it correctly or I am not reading it correctly. I was given the following instructions to set the cookie. It appears to be...
0
by: Chris Rebert | last post by:
See the 'cookie' module: http://www.python.org/doc/2.5.2/lib/module-Cookie.html Also: A. In the future, Google is your friend! That page is the top hit for "python cookie" for Christ's sake;...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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.