Go Back   Forum Care Forums > Development Reference Area > Webmaster Topics

Reply
 
LinkBack Thread Tools Display Modes
Setting cookie in header
Old
  (#1)
Charles Sweeney
Guest
 
Posts: n/a
Default Setting cookie in header - 05-14-2007, 01:27 AM


With a PHP page I can easily set a cookie. What about an HTML page? Can
one configure the webserver to set a cookie in the header so that when the
HTML page is requested, a cookie is set on the visitor's computer?

--
Charles Sweeney
http://CharlesSweeney.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Setting cookie in header
Old
  (#2)
cristina
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

Charles Sweeney wrote:

> With a PHP page I can easily set a cookie. What about an HTML page? Can
> one configure the webserver to set a cookie in the header so that when the
> HTML page is requested, a cookie is set on the visitor's computer?
>
> --
> Charles Sweeney
> http://CharlesSweeney.com


maybe by using javascript(?)
(for browsers with javascript enabled i suppose)

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#3)
cristina
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

Charles Sweeney wrote:

> With a PHP page I can easily set a cookie. What about an HTML page? Can
> one configure the webserver to set a cookie in the header so that when the
> HTML page is requested, a cookie is set on the visitor's computer?
>
> --
> Charles Sweeney
> http://CharlesSweeney.com


Sorry, me again, there is this meta tag to use in an HTML document
<meta http-equiv="Set-Cookie" content="value=n;expires=date; path=url">

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#4)
cristina
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

Charles Sweeney wrote:

> With a PHP page I can easily set a cookie. What about an HTML page? Can
> one configure the webserver to set a cookie in the header so that when the
> HTML page is requested, a cookie is set on the visitor's computer?
>
> --
> Charles Sweeney
> http://CharlesSweeney.com


Sorry, me again again.
If it does not crash the server,
this might work on some Apache servers(?)

<Files page.html>
Header add Set-Cookie "name=value"
</Files>

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#5)
cristina
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

Charles Sweeney wrote:

> With a PHP page I can easily set a cookie. What about an HTML page? Can
> one configure the webserver to set a cookie in the header so that when the
> HTML page is requested, a cookie is set on the visitor's computer?
>
> --
> Charles Sweeney
> http://CharlesSweeney.com


Definitely my postings are jinxed today. I meant
<Files page.html>
Header add Set-Cookie "name=value"
</Files>
in the .htaccess file (I did not try this).

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#6)
Charles Sweeney
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

cristina wrote

> Charles Sweeney wrote:
>
>> With a PHP page I can easily set a cookie. What about an HTML page?
>> Can one configure the webserver to set a cookie in the header so that
>> when the HTML page is requested, a cookie is set on the visitor's
>> computer?
>>
>> --
>> Charles Sweeney
>> http://CharlesSweeney.com

>
> Definitely my postings are jinxed today. I meant
> <Files page.html>
> Header add Set-Cookie "name=value"
> </Files>
> in the .htaccess file (I did not try this).


Superb Cristina! (All your posts!)

XX

--
Charles Sweeney
http://CharlesSweeney.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#7)
Charles Sweeney
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

cristina wrote

> Charles Sweeney wrote:
>
>> With a PHP page I can easily set a cookie. What about an HTML page?
>> Can one configure the webserver to set a cookie in the header so that
>> when the HTML page is requested, a cookie is set on the visitor's
>> computer?
>>
>> --
>> Charles Sweeney
>> http://CharlesSweeney.com

>
> Sorry, me again, there is this meta tag to use in an HTML document
> <meta http-equiv="Set-Cookie" content="value=n;expires=date;
> path=url">


I went for this option...worked a treat!

The things you learn, I thought it had to be in the header.

--
Charles Sweeney
http://CharlesSweeney.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#8)
cristina
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:27 AM

Charles Sweeney wrote:

> > Sorry, me again, there is this meta tag to use in an HTML document
> > <meta http-equiv="Set-Cookie" content="value=n;expires=date;
> > path=url">

>
> I went for this option...worked a treat!
>
> The things you learn, I thought it had to be in the header.
>
> --
> Charles Sweeney
> http://CharlesSweeney.com


I suppose it is up to the server
to sort of patch the meta http-equiv tags in the HTTP header.

There is a subtle and obvious difference between setting a cookie
with a CGI script via the HTTP header and
with the meta http-equiv tag
in the <head> element of a static HTML page.
The cookie set by the script via the HTTP header is in the HTTP header
when the page is accessed with HTTP request of
both HEAD and GET methods,
while the cookie set via the meta tag inside the HTML page is set
of course only when the page is accessed with the GET method,
because the cookie cannot be "seen"
unless the page content is accessed (as you know the HEAD method
does not download/access the URL content).
You can see this with the HTTP header checker
http://www.asymptoticdesign.co.uk/cgi-bin/index.pl
and with two very simple test pages I made,
one with a cookie set by a Perl script via the HTTP header
http://www.asymptoticdesign.co.uk/cg...okie_header.pl
and one with a cookie set via the meta http-equiv Set-Cookie tag
http://www.asymptoticdesign.co.uk/au...okie_meta.html

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Setting cookie in header
Old
  (#9)
Charles Sweeney
Guest
 
Posts: n/a
Default Re: Setting cookie in header - 05-14-2007, 01:28 AM

cristina wrote

> Charles Sweeney wrote:
>
>> > Sorry, me again, there is this meta tag to use in an HTML document
>> > <meta http-equiv="Set-Cookie" content="value=n;expires=date;
>> > path=url">

>>
>> I went for this option...worked a treat!
>>
>> The things you learn, I thought it had to be in the header.
>>
>> --
>> Charles Sweeney
>> http://CharlesSweeney.com

>
> I suppose it is up to the server
> to sort of patch the meta http-equiv tags in the HTTP header.
>
> There is a subtle and obvious difference between setting a cookie
> with a CGI script via the HTTP header and
> with the meta http-equiv tag
> in the <head> element of a static HTML page.
> The cookie set by the script via the HTTP header is in the HTTP header
> when the page is accessed with HTTP request of
> both HEAD and GET methods,
> while the cookie set via the meta tag inside the HTML page is set
> of course only when the page is accessed with the GET method,
> because the cookie cannot be "seen"
> unless the page content is accessed (as you know the HEAD method
> does not download/access the URL content).
> You can see this with the HTTP header checker
> http://www.asymptoticdesign.co.uk/cgi-bin/index.pl
> and with two very simple test pages I made,
> one with a cookie set by a Perl script via the HTTP header
> http://www.asymptoticdesign.co.uk/cgi-

bin/aux_test_cookie/set_cookie_he
> ader.pl and one with a cookie set via the meta http-equiv Set-Cookie
> tag
> http://www.asymptoticdesign.co.uk/au...okie_meta.html


Good work Cristina, thank you very much. I like your nice clean design.

--
Charles Sweeney
http://CharlesSweeney.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

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 On





Contact Us - Forum Care Forums - Archive - Top