Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Send cookie to server?

Reply
Thread Tools

Send cookie to server?

 
 
Martin
Guest
Posts: n/a
 
      03-31-2006
How can I send a cookie (that was created by client-side scripting) to
the server?

It's my understanding that if the cookie had been created by the
server, it would be automatically submitted when a request is sent to
that server. Is it possible to achieve this same behavior with a
cookie that was not created by the server?
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      03-31-2006
Martin wrote:

> How can I send a cookie (that was created by client-side scripting) to
> the server?


Issue any old http request, the browser will handle it automatically.

> It's my understanding that if the cookie had been created by the
> server, it would be automatically submitted when a request is sent to
> that server. Is it possible to achieve this same behavior with a
> cookie that was not created by the server?


A cookie, is a cookie, is a cookie. It doesn't matter how it was created.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
Martin
Guest
Posts: n/a
 
      03-31-2006
On Fri, 31 Mar 2006 18:36:28 +0100, David Dorward <>
wrote:

>Martin wrote:
>
>> How can I send a cookie (that was created by client-side scripting) to
>> the server?

>
>Issue any old http request, the browser will handle it automatically.
>
>> It's my understanding that if the cookie had been created by the
>> server, it would be automatically submitted when a request is sent to
>> that server. Is it possible to achieve this same behavior with a
>> cookie that was not created by the server?

>
>A cookie, is a cookie, is a cookie. It doesn't matter how it was created.


David:

Thank you, thank you, thank you. I have struggled with this for
several hours. It never dawned on me to simply check the cookies
collection on the server to see what was coming in.

Now, please educate me about something: how does the browser know
which cookies to send? Is it going to be sending those
client-side-created-cookies to every server that the user goes to from
now on?

Martin


 
Reply With Quote
 
Benjamin Niemann
Guest
Posts: n/a
 
      03-31-2006
Martin wrote:

> How can I send a cookie (that was created by client-side scripting) to
> the server?
>
> It's my understanding that if the cookie had been created by the
> server, it would be automatically submitted when a request is sent to
> that server. Is it possible to achieve this same behavior with a
> cookie that was not created by the server?


The cookie gets sent to the server (on subsequent requests), which sent the
document. You may have to specify the 'path' parameter (which defaults to
the directory of the document), if the document is in a subdirectory and
the cookie should be sent to documents in another directory. E.g. cookie
created in /foo/doc1 and /bar/doc2 should recieve it. By default only
documents in /foo will get the cookie.
If you want the cookie to be sent to a document on another domain, you also
have to specify the 'domain' parameter.

document.cookie = 'foobar=this is the value; path=/; domain=www.example.com'

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      03-31-2006
Martin wrote:

> Now, please educate me about something: how does the browser know
> which cookies to send? Is it going to be sending those
> client-side-created-cookies to every server that the user goes to from
> now on?


Cookies are host name specific (although I believe there are means to state
that they can be used on multiple hosts in the same domain).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is different between Request.Cookie and Response.Cookie ad ASP .Net 2 01-27-2006 12:54 PM
Cookie Question (IP as domain and cookie file location) =?Utf-8?B?UGF1bA==?= ASP .Net 1 01-10-2006 08:37 PM
Any downsides to cookie assignment inside custom class using HttpContext.Current? ASP.NET 2.0 cookie fix? ASP .Net 2 08-17-2005 06:43 AM
Cookie and Session Cookie Questions. Shapper ASP .Net 1 04-27-2005 11:20 AM
Session cookie? Browser instance cookie? Ben ASP .Net 3 06-03-2004 03:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57