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

Reply via email to