This is a good clean solution for cookies.
It would work with the current JHP interface.
It could be added to J Wiki CGI as a comment
to discuss.
   http://www.jsoftware.com/jwiki/CGI/Comments

However, for long-term, it is better to
disassociate the header creation from
page rendering. For example, if Buffer>0 then
the headers can be added any time. One solution
is to have a separate printhead. But it is 
better to maintain headers and cookies as
dictionaries that can be modified during response
generation.

See some ideas about a future CGI design and API at
  http://www.jsoftware.com/jwiki/CGI


--- "Sherlock, Ric" <[EMAIL PROTECTED]> wrote:

> I've been investigating JHP.
> I was interested in setting cookies, but couldn't find any existing
> facility to do so.
> After some research into how cookies are set etc, I came up with the two
> functions below (which I'm sure could be much improved/simplified) that
> could be added to jhp.ijs.
> 
> In a JHP page they could be used like this.
> <% SetCookie 'foo=bar;' %>
> <% DeleteCookie 'oldfoo' %>
> <% ContentType'text/html' %>
> <html><head>...
> 
> I'm obviously new to this CGI stuff so I'd be interested in any
> comments, criticisms or alternative suggestions!
> 
> Ric
> 
> NB.*SetCookie v writes line to delete/expire a cookie
> NB. y is string to set cookie
> NB. e.g. SetCookie 'foo=bar;'
> NB. e.g. SetCookie 'foo=bar; domain=domain.com; path=/; expires=Fri,
> 29-Mar-2007 13:46:00 GMT'
> SetCookie=: 3 : 0
>   if. 0 <: nc<'CookiesSet_j_' do.
>     CookiesSet_j_=: CookiesSet_j_;y    
>   else.
>     CookiesSet_j_=: y    
>   end.
>  print 'Set-Cookie: ',":y
> )
> 
> NB.*DeleteCookie v writes line to delete/expire a cookie
> NB. y is string - name of cookie to delete
> NB. e.g. DeleteCookie 'foo'
> DeleteCookie=: 3 : 0
>   ck=.y,'=;'
>   expire=. ' expires=Thu, 01-Jan-1970 00:00:00 GMT;'
>   SetCookie ck,expire
> )
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to