470,593 Members | 2,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,593 developers. It's quick & easy.

Problem with cookies

This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8
May 10 '06 #1
12 2468
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get called
all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8

May 10 '06 #2
What is the value of mstrMyValue?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"MSDN" <sq**********@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP02.phx.gbl...
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8


May 10 '06 #3
Kevin,

Even if mstrMyValue = "SomeValue" it still does not work
the Cookie value is lost between pages.

Thanks

B

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uh*************@TK2MSFTNGP02.phx.gbl...
What is the value of mstrMyValue?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"MSDN" <sq**********@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP02.phx.gbl...
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8



May 11 '06 #4
I have no chache settings...

MSDN wrote:
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get called
all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8


May 11 '06 #5
My main problem is that I set cookie's value in Default.aspx, and when I
refresh the page or visit another page, I'm unable to retreive
cookie's value...

I think that cookie is only saved between pages refresh instead of
having a 'site' cookie...

I really try to applicate tutorials, but I think I'm missing something...

Dumbell wrote:
Kevin,

Even if mstrMyValue = "SomeValue" it still does not work
the Cookie value is lost between pages.

Thanks

B

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uh*************@TK2MSFTNGP02.phx.gbl...
What is the value of mstrMyValue?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"MSDN" <sq**********@hotmail.com> wrote in message
news:eW**************@TK2MSFTNGP02.phx.gbl...
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8


May 11 '06 #6
This is very strange I am having the same problem you are having using your
example.
it seems that the cookie is saved for a specific page and not the entire
website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
I have no chache settings...

MSDN wrote:
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8


May 11 '06 #7
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
This is very strange I am having the same problem you are having using your
example.
it seems that the cookie is saved for a specific page and not the entire
website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
I have no chache settings...

MSDN wrote:
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
This is the first time I try to use cookies, and despite of reading some
tutotials, I'm have real trouble to make it work correctly. My cookie
reading code is in Master Page. When I click on a test button (in a WEb
User Control inside the aspx page), cookie value is displayed in Master
Page but if I go to another page, no value is displayed...

I need to be able tu use cookie's value across all the site... What am I
doing wrong ?

Code in WebUser control, this code on a button click event:

8<---------------------

HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
HttpContext.Current.Response.Cookies["TestValue"].Expires =
DateTime.Today.AddDays(365);

--------------------->8

And this code in OnPreRender of my Master page:

8<---------------------

if (Request.Cookies["TestValue"] != null){
litCookieTest.Text = Response.Cookies["TestValue"].Value;
}else{
litCookieTest.Text = Request.Cookies["TestValue"].Value;
}
--------------------->8

May 11 '06 #8
Patxi,

Have you tired this without master page?
I am using IIS 5.1, Win XP Pro

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
This is very strange I am having the same problem you are having using
your example.
it seems that the cookie is saved for a specific page and not the entire
website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is
happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
I have no chache settings...

MSDN wrote:
Patxi,

If you put a breakpoint in the OnPreRender event handler does it get
called all the time
It is not called all the time. Is it due to caching??

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
> This is the first time I try to use cookies, and despite of reading
> some tutotials, I'm have real trouble to make it work correctly. My
> cookie reading code is in Master Page. When I click on a test button
> (in a WEb User Control inside the aspx page), cookie value is
> displayed in Master Page but if I go to another page, no value is
> displayed...
>
> I need to be able tu use cookie's value across all the site... What am
> I doing wrong ?
>
> Code in WebUser control, this code on a button click event:
>
> 8<---------------------
>
> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
> HttpContext.Current.Response.Cookies["TestValue"].Expires =
> DateTime.Today.AddDays(365);
>
> --------------------->8
>
> And this code in OnPreRender of my Master page:
>
> 8<---------------------
>
> if (Request.Cookies["TestValue"] != null){
> litCookieTest.Text = Response.Cookies["TestValue"].Value;
> }else{
> litCookieTest.Text = Request.Cookies["TestValue"].Value;
> }
> --------------------->8

May 11 '06 #9
I stopped trying it, I'm trying Profile system... But I have a big
problem, since it works against SQL and I'm developping a 3 tier
application, so I would like to use my BLL or a single XML file to store
profiles, but I'm unable to find an implemention in XML...

I'm studying
http://msdn.microsoft.com/library/de...ovMod_Prt5.asp
but I can't find a more realistic example of xml driven
ProfileProvider... Can you point me to a more practical site ?

Thanks

MSDN wrote:
Patxi,

Have you tired this without master page?
I am using IIS 5.1, Win XP Pro

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
This is very strange I am having the same problem you are having using
your example.
it seems that the cookie is saved for a specific page and not the entire
website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is
happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
I have no chache settings...

MSDN wrote:
> Patxi,
>
> If you put a breakpoint in the OnPreRender event handler does it get
> called all the time
> It is not called all the time. Is it due to caching??
>
> SA
>
> "Patxi" <pa***@yahoo.com> wrote in message
> news:44*********************@news.free.fr...
>> This is the first time I try to use cookies, and despite of reading
>> some tutotials, I'm have real trouble to make it work correctly. My
>> cookie reading code is in Master Page. When I click on a test button
>> (in a WEb User Control inside the aspx page), cookie value is
>> displayed in Master Page but if I go to another page, no value is
>> displayed...
>>
>> I need to be able tu use cookie's value across all the site... What am
>> I doing wrong ?
>>
>> Code in WebUser control, this code on a button click event:
>>
>> 8<---------------------
>>
>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
>> DateTime.Today.AddDays(365);
>>
>> --------------------->8
>>
>> And this code in OnPreRender of my Master page:
>>
>> 8<---------------------
>>
>> if (Request.Cookies["TestValue"] != null){
>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
>> }else{
>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
>> }
>> --------------------->8


May 11 '06 #10
Incredible !!!

I'm testing with Profile and I'm having the same problem...

I create a Web User control (ProfileViewer.ascx) with a label, and this
code in the Page_Load event:

Label1.Text = Profile.FirstName;

I have another Web User control (ProfileSetCtrl.ascx) with a button and
this code on button's click event:

Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)

In my Default.aspx file, I scan for jpgs in a directory and load one
ProfileSetCtrl.ascx per jpg, passing the jpg file path...

I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
value configured in Web.config displayed...

I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...

What am I missing ?

Thanks

MSDN wrote:
Patxi,

Have you tired this without master page?
I am using IIS 5.1, Win XP Pro

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
This is very strange I am having the same problem you are having using
your example.
it seems that the cookie is saved for a specific page and not the entire
website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and the
WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is
happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
I have no chache settings...

MSDN wrote:
> Patxi,
>
> If you put a breakpoint in the OnPreRender event handler does it get
> called all the time
> It is not called all the time. Is it due to caching??
>
> SA
>
> "Patxi" <pa***@yahoo.com> wrote in message
> news:44*********************@news.free.fr...
>> This is the first time I try to use cookies, and despite of reading
>> some tutotials, I'm have real trouble to make it work correctly. My
>> cookie reading code is in Master Page. When I click on a test button
>> (in a WEb User Control inside the aspx page), cookie value is
>> displayed in Master Page but if I go to another page, no value is
>> displayed...
>>
>> I need to be able tu use cookie's value across all the site... What am
>> I doing wrong ?
>>
>> Code in WebUser control, this code on a button click event:
>>
>> 8<---------------------
>>
>> HttpContext.Current.Response.Cookies["TestValue"].Value = mstrMyValue;
>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
>> DateTime.Today.AddDays(365);
>>
>> --------------------->8
>>
>> And this code in OnPreRender of my Master page:
>>
>> 8<---------------------
>>
>> if (Request.Cookies["TestValue"] != null){
>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
>> }else{
>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
>> }
>> --------------------->8


May 11 '06 #11
This is extremely frustration for me also I have no Idea
It seems no one else is reading this at all

May be bring this question back to the top of the list and lets start over
again.

Sorry...

SA
"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
Incredible !!!

I'm testing with Profile and I'm having the same problem...

I create a Web User control (ProfileViewer.ascx) with a label, and this
code in the Page_Load event:

Label1.Text = Profile.FirstName;

I have another Web User control (ProfileSetCtrl.ascx) with a button and
this code on button's click event:

Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)

In my Default.aspx file, I scan for jpgs in a directory and load one
ProfileSetCtrl.ascx per jpg, passing the jpg file path...

I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
value configured in Web.config displayed...

I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...

What am I missing ?

Thanks

MSDN wrote:
Patxi,

Have you tired this without master page?
I am using IIS 5.1, Win XP Pro

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
This is very strange I am having the same problem you are having using
your example.
it seems that the cookie is saved for a specific page and not the
entire website.
I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and
the WebServer with PORT NUMBER etc...
So I moved the sample I have to a web site and the same thing is
happening.
The cookie does not have to persist.
Still looking for an answer.

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
> I have no chache settings...
>
> MSDN wrote:
>> Patxi,
>>
>> If you put a breakpoint in the OnPreRender event handler does it get
>> called all the time
>> It is not called all the time. Is it due to caching??
>>
>> SA
>>
>> "Patxi" <pa***@yahoo.com> wrote in message
>> news:44*********************@news.free.fr...
>>> This is the first time I try to use cookies, and despite of reading
>>> some tutotials, I'm have real trouble to make it work correctly. My
>>> cookie reading code is in Master Page. When I click on a test
>>> button (in a WEb User Control inside the aspx page), cookie value is
>>> displayed in Master Page but if I go to another page, no value is
>>> displayed...
>>>
>>> I need to be able tu use cookie's value across all the site... What
>>> am I doing wrong ?
>>>
>>> Code in WebUser control, this code on a button click event:
>>>
>>> 8<---------------------
>>>
>>> HttpContext.Current.Response.Cookies["TestValue"].Value =
>>> mstrMyValue;
>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
>>> DateTime.Today.AddDays(365);
>>>
>>> --------------------->8
>>>
>>> And this code in OnPreRender of my Master page:
>>>
>>> 8<---------------------
>>>
>>> if (Request.Cookies["TestValue"] != null){
>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
>>> }else{
>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
>>> }
>>> --------------------->8


May 11 '06 #12
I solved it adding this:

this.Context.Response.Redirect(this.Context.Reques t.Url.ToString());

after setting profile's value...

MSDN wrote:
This is extremely frustration for me also I have no Idea
It seems no one else is reading this at all

May be bring this question back to the top of the list and lets start over
again.

Sorry...

SA
"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
Incredible !!!

I'm testing with Profile and I'm having the same problem...

I create a Web User control (ProfileViewer.ascx) with a label, and this
code in the Page_Load event:

Label1.Text = Profile.FirstName;

I have another Web User control (ProfileSetCtrl.ascx) with a button and
this code on button's click event:

Profile.FirstName = mstrMyValue; (mstrMyValue is the path of jpg file)

In my Default.aspx file, I scan for jpgs in a directory and load one
ProfileSetCtrl.ascx per jpg, passing the jpg file path...

I click on button displaying 1.jpg, ProfileViewer.ascx shows the default
value configured in Web.config displayed...

I click on button displaying 3.jpg, and ProfileViewer.ascx shows 1.jpg...

What am I missing ?

Thanks

MSDN wrote:
Patxi,

Have you tired this without master page?
I am using IIS 5.1, Win XP Pro

SA

"Patxi" <pa***@yahoo.com> wrote in message
news:44*********************@news.free.fr...
For the record, I'm using an IIS virtual directory, running IIS 5.0...

MSDN wrote:
> This is very strange I am having the same problem you are having using
> your example.
> it seems that the cookie is saved for a specific page and not the
> entire website.
> I suspected that may be it has to do with ASP.NET 2.0 and VS 2005 and
> the WebServer with PORT NUMBER etc...
> So I moved the sample I have to a web site and the same thing is
> happening.
> The cookie does not have to persist.
> Still looking for an answer.
>
> SA
>
> "Patxi" <pa***@yahoo.com> wrote in message
> news:44*********************@news.free.fr...
>> I have no chache settings...
>>
>> MSDN wrote:
>>> Patxi,
>>>
>>> If you put a breakpoint in the OnPreRender event handler does it get
>>> called all the time
>>> It is not called all the time. Is it due to caching??
>>>
>>> SA
>>>
>>> "Patxi" <pa***@yahoo.com> wrote in message
>>> news:44*********************@news.free.fr...
>>>> This is the first time I try to use cookies, and despite of reading
>>>> some tutotials, I'm have real trouble to make it work correctly. My
>>>> cookie reading code is in Master Page. When I click on a test
>>>> button (in a WEb User Control inside the aspx page), cookie value is
>>>> displayed in Master Page but if I go to another page, no value is
>>>> displayed...
>>>>
>>>> I need to be able tu use cookie's value across all the site... What
>>>> am I doing wrong ?
>>>>
>>>> Code in WebUser control, this code on a button click event:
>>>>
>>>> 8<---------------------
>>>>
>>>> HttpContext.Current.Response.Cookies["TestValue"].Value =
>>>> mstrMyValue;
>>>> HttpContext.Current.Response.Cookies["TestValue"].Expires =
>>>> DateTime.Today.AddDays(365);
>>>>
>>>> --------------------->8
>>>>
>>>> And this code in OnPreRender of my Master page:
>>>>
>>>> 8<---------------------
>>>>
>>>> if (Request.Cookies["TestValue"] != null){
>>>> litCookieTest.Text = Response.Cookies["TestValue"].Value;
>>>> }else{
>>>> litCookieTest.Text = Request.Cookies["TestValue"].Value;
>>>> }
>>>> --------------------->8

May 12 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by TJO | last post: by
2 posts views Thread by Netanel | last post: by
7 posts views Thread by patbaudy | last post: by
1 post views Thread by rushik | last post: by
reply views Thread by Andrť | last post: by
3 posts views Thread by lawrence k | last post: by
3 posts views Thread by jacusp | last post: by
7 posts views Thread by cmrchs | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.