Dear all,
I try to make some test on how to use basic cookie but get some trouble in
the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then
If Request.Browser.Cookies Then
If Not IsNothing(Request.Cookies("PS")) Then
Session("Server") = Request.Cookies("PS").Value
txtServerName.Text = Session("Server")
End If
End If
end if
Somewhere in my code I set the cookie as follow :
If Request.Browser.Cookies Then
Dim ck_SrvName As New HttpCookie("PS")
ck_SrvName.Value = txtServerName.Text
Response.Cookies.Add(ck_SrvName)
End If
When I restart my application, my cookies object do not return it s content,
what am I doing wrong in here ?
thanks for your help
regards
serge 4 1296
I'm not sure, but a guess is that your cookie is expiring. Are you closing
your browser and restarting when you
"restart your application" ?
If so, by default cookies only exist as long as the browser is open, to
change that you must give the cookie an expiry before adding it to the
response, something like:
cookie.Expires = DateTime.MaxValue ' Never Expires
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:83**********************************@microsof t.com... Dear all,
I try to make some test on how to use basic cookie but get some trouble in the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then If Request.Browser.Cookies Then If Not IsNothing(Request.Cookies("PS")) Then Session("Server") = Request.Cookies("PS").Value txtServerName.Text = Session("Server") End If
End If end if
Somewhere in my code I set the cookie as follow :
If Request.Browser.Cookies Then Dim ck_SrvName As New HttpCookie("PS") ck_SrvName.Value = txtServerName.Text Response.Cookies.Add(ck_SrvName) End If
When I restart my application, my cookies object do not return it s content, what am I doing wrong in here ?
thanks for your help regards serge
And added to Karl's point..
When ever you're running session / cookie based programs, don't expect
proper results in debug mode.
Compile the code and execute in separate browser, not thru the F5'ing all
the time. So, that you can check the consistency of the code you've written.
--
Vadivel Kumar http://blogs.wdevs.com/varahe
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:Oj**************@TK2MSFTNGP14.phx.gbl... I'm not sure, but a guess is that your cookie is expiring. Are you closing your browser and restarting when you "restart your application" ?
If so, by default cookies only exist as long as the browser is open, to change that you must give the cookie an expiry before adding it to the response, something like:
cookie.Expires = DateTime.MaxValue ' Never Expires
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX! "serge calderara" <se************@discussions.microsoft.com> wrote in message news:83**********************************@microsof t.com... Dear all,
I try to make some test on how to use basic cookie but get some trouble
in the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then If Request.Browser.Cookies Then If Not IsNothing(Request.Cookies("PS")) Then Session("Server") = Request.Cookies("PS").Value txtServerName.Text = Session("Server") End If
End If end if
Somewhere in my code I set the cookie as follow :
If Request.Browser.Cookies Then Dim ck_SrvName As New HttpCookie("PS") ck_SrvName.Value = txtServerName.Text Response.Cookies.Add(ck_SrvName) End If
When I restart my application, my cookies object do not return it s content, what am I doing wrong in here ?
thanks for your help regards serge
Yes this is what I am doing, I am closing the browser each time to test that.
I will try to set the expiration parameter
thnaks
serge
"Karl Seguin" wrote: I'm not sure, but a guess is that your cookie is expiring. Are you closing your browser and restarting when you "restart your application" ?
If so, by default cookies only exist as long as the browser is open, to change that you must give the cookie an expiry before adding it to the response, something like:
cookie.Expires = DateTime.MaxValue ' Never Expires
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX! "serge calderara" <se************@discussions.microsoft.com> wrote in message news:83**********************************@microsof t.com... Dear all,
I try to make some test on how to use basic cookie but get some trouble in the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then If Request.Browser.Cookies Then If Not IsNothing(Request.Cookies("PS")) Then Session("Server") = Request.Cookies("PS").Value txtServerName.Text = Session("Server") End If
End If end if
Somewhere in my code I set the cookie as follow :
If Request.Browser.Cookies Then Dim ck_SrvName As New HttpCookie("PS") ck_SrvName.Value = txtServerName.Text Response.Cookies.Add(ck_SrvName) End If
When I restart my application, my cookies object do not return it s content, what am I doing wrong in here ?
thanks for your help regards serge
Thansk , it works
I have add an expiration date and time an now when I colse my browser and
restart I am able to get the value back
by the wa where doe cokkies get sotre, I try to find out if my cooki has
been created, but how are they identify? sounds crypred
regards
serge
"Karl Seguin" wrote: I'm not sure, but a guess is that your cookie is expiring. Are you closing your browser and restarting when you "restart your application" ?
If so, by default cookies only exist as long as the browser is open, to change that you must give the cookie an expiry before adding it to the response, something like:
cookie.Expires = DateTime.MaxValue ' Never Expires
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX! "serge calderara" <se************@discussions.microsoft.com> wrote in message news:83**********************************@microsof t.com... Dear all,
I try to make some test on how to use basic cookie but get some trouble in the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then If Request.Browser.Cookies Then If Not IsNothing(Request.Cookies("PS")) Then Session("Server") = Request.Cookies("PS").Value txtServerName.Text = Session("Server") End If
End If end if
Somewhere in my code I set the cookie as follow :
If Request.Browser.Cookies Then Dim ck_SrvName As New HttpCookie("PS") ck_SrvName.Value = txtServerName.Text Response.Cookies.Add(ck_SrvName) End If
When I restart my application, my cookies object do not return it s content, what am I doing wrong in here ?
thanks for your help regards serge This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: collie |
last post by:
Hi,
I have an asp page that needs to create 2 different cookies: one for
the admin and one for the user. The code that I have to work with was
created by someone else. the page first requires to...
|
by: |
last post by:
Please help.
After a number of wrong turns and experiments I need advice on login
management system to secure our web pages without inconveniencing our
visitors or our internal staff.
What I...
|
by: Bennett F. Dill |
last post by:
Thanks for reading. I'm having problems with cookies from asp to asp.net
and back!
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...
|
by: Calvin KD |
last post by:
Hi everyone,
Can someone tell me what's wrong with the way that i read a cookie as below:
private void Page_Load(object sender, System.EventArgs e)
{
Response.Cookies.Clear();
HttpCookie...
|
by: Alan Silver |
last post by:
Hello,
I am having a problem setting and resetting cookies. I'm sure I just
doing something really stupid as this is such a basic issue, but I can
find any answer. Please can someone help me?
...
|
by: Phillip N Rounds |
last post by:
I'm having trouble with using cookies to monitor the stages of login.
I have a two stage Registration page ( register.aspx ) and my target page
( MyPage.aspx )
I'm using a cookie named LoginStatus...
|
by: isaac2004 |
last post by:
hi i have a basic asp page that acts as an online bookstore. on my cart
page i am having trouble generating 3 numbers; a subtotal, a shipping
total, and a final price. here is my code
i would...
|
by: isaac2004 |
last post by:
hi i am creating a basic asp site that uses cookies to manage a cart
for an online store. whenever i open this page without adding anything
to the cart. i get an error message.
here is my code
...
|
by: AppleBag |
last post by:
I'm having the worst time trying to login to myspace through code. Can
someone tell me how to do this? Please try it yourself before replying,
only because I have asked this a couple of times in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |