Is this a bug? I am trying to write a cookie that can be accessed by
various .Net applications on our domain. However, whenever I add the
domain property to the cookie, no errors get thrown but the cookie
doesn't get written. I am trying this from my localhost using
vs2003, .net framework 1.1, windows xp prof. Sample code I am testing
with is below.
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Get cookie from current request.
Dim cookie As HttpCookie
cookie = Request.Cookies.Get("DateCookieExample")
' Check if cookie exists in the current request
If (cookie Is Nothing) Then
' Create cookie.
cookie = New HttpCookie("DateCookieExample")
' Set value of cookie to current date time.
cookie.Value = "This is the cookie value"
' Set Domain for the cookie (limits scope of the
cookie)
cookie.Domain = ".CTDOL.STATE.CT.US"
'******* If the above line is active the cookie does NOT get written
out
'******* If the above line is commented out the cookie gets written
'******* What am I doing wrong??? It seemed simple.
' Set cookie to expire in 1 minutes.
cookie.Expires = DateTime.Now.AddMinutes(1).ToString
' Insert the cookie in the current HttpResponse.
Response.Cookies.Add(cookie)
Response.Write("Cookie Created")
Else
Response.Write("Cookie retrieved from client")
End If
End Sub 2 2762
are you using the domain name when you access the page? if you set the
cookie domain to .mydomain.com then the url must have that suffix as the
server name in the url. http://foo.mydomain.com/somepage.aspx
or for security the browser will not save, nor will it send to a site
that doesn't match.
-- bruce (sqlwork.com) ke***********@po.state.ct.us wrote:
Is this a bug? I am trying to write a cookie that can be accessed by
various .Net applications on our domain. However, whenever I add the
domain property to the cookie, no errors get thrown but the cookie
doesn't get written. I am trying this from my localhost using
vs2003, .net framework 1.1, windows xp prof. Sample code I am testing
with is below.
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Get cookie from current request.
Dim cookie As HttpCookie
cookie = Request.Cookies.Get("DateCookieExample")
' Check if cookie exists in the current request
If (cookie Is Nothing) Then
' Create cookie.
cookie = New HttpCookie("DateCookieExample")
' Set value of cookie to current date time.
cookie.Value = "This is the cookie value"
' Set Domain for the cookie (limits scope of the
cookie)
cookie.Domain = ".CTDOL.STATE.CT.US"
'******* If the above line is active the cookie does NOT get written
out
'******* If the above line is commented out the cookie gets written
'******* What am I doing wrong??? It seemed simple.
' Set cookie to expire in 1 minutes.
cookie.Expires = DateTime.Now.AddMinutes(1).ToString
' Insert the cookie in the current HttpResponse.
Response.Cookies.Add(cookie)
Response.Write("Cookie Created")
Else
Response.Write("Cookie retrieved from client")
End If
End Sub
Thank you, worked like a charm! I wasn't including the entire domain
name in the URL when I was calling the page.
On Oct 29, 12:24 pm, bruce barker <nos...@nospam.comwrote:
are you using the domain name when you access the page? if you set the
cookie domain to .mydomain.com then the url must have that suffix as the
server name in the url.
http://foo.mydomain.com/somepage.aspx
or for security the browser will not save, nor will it send to a site
that doesn't match.
-- bruce (sqlwork.com)
kelly.pear...@po.state.ct.us wrote:
Is this a bug? I am trying to write a cookie that can be accessed by
various .Net applications on our domain. However, whenever I add the
domain property to the cookie, no errors get thrown but the cookie
doesn't get written. I am trying this from my localhost using
vs2003, .net framework 1.1, windows xp prof. Sample code I am testing
with is below.
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Get cookie from current request.
Dim cookie As HttpCookie
cookie = Request.Cookies.Get("DateCookieExample")
' Check if cookie exists in the current request
If (cookie Is Nothing) Then
' Create cookie.
cookie = New HttpCookie("DateCookieExample")
' Set value of cookie to current date time.
cookie.Value = "This is the cookie value"
' Set Domain for the cookie (limits scope of the
cookie)
cookie.Domain = ".CTDOL.STATE.CT.US"
'******* If the above line is active the cookie does NOT get written
out
'******* If the above line is commented out the cookie gets written
'******* What am I doing wrong??? It seemed simple.
' Set cookie to expire in 1 minutes.
cookie.Expires = DateTime.Now.AddMinutes(1).ToString
' Insert the cookie in the current HttpResponse.
Response.Cookies.Add(cookie)
Response.Write("Cookie Created")
Else
Response.Write("Cookie retrieved from client")
End If
End Sub- Hide quoted text -
- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
I''m having a problem with cookies that is driving me insane :).
- If a user comes to http://domain.com and a cookie is set for them, then the user for whatever reason jumps to http://www.domain.com...
|
by: Tony Archer |
last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior
post.)
Gentlemen, your urgent help is needed in solving a STRANGE problem.
I have two servers a dev box, and a...
|
by: socialism001 |
last post by:
I'm trying to store a value in a cookie but its not working. Can
anyone see what I might be doing wrong.
Thanks,
Chris
~~~~~~~~~~~~~~~~~~
<script language="javascript">...
|
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...
|
by: Doug |
last post by:
An ASP.NET session cookie set on "www.mydomain.com" can not be accessed on
"search.mydomain.com"; hence, a new session and cookie are being created on
every sub-domain.
This is occuring because...
|
by: CR1 |
last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
|
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...
|
by: kelvlam |
last post by:
Hello all,
I'm still a bit new with JavaScript, and I hope the guru here can shed
some light for me. It's regarding handling cookie and the
case-sensitive nature of JavaScript itself.
My...
|
by: ken |
last post by:
How to remove specified cookie (via a given name) in cookie jar?
I have the following code, but how can I remove a specified cookie in
the cookie jar?
cj = cookielib.LWPCookieJar()
if cj is...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |