|Post date: 2007-03-15 21:12|
Setting cookies from a LS OpenAgent:
Print "Status: 200"
Print |Set-Cookie: user=Tomas Nielsen; expires=Wed, 9 Dec 2009 21:00:02 GMT; path=/|
Print "Content-type:text/html; charset=UTF-8" ' Format a nice header telling the content type.
Print |Cache-control: no-cache, no-store, must-revalidate| ' Not a good idea to cache this.
Print |document.location.href = "/";| ' Send the user to the start page
You would probably want to change the content part of the cookie but you get the idea. Leave out the expires part if you want the cookie to die when the user closes the browser.
The "path" part is best left at pointing at the root. In domino situations you will most probably get into trouble if you set this one to point to a database. It is really hard to try to debug why your cookie is not available if you set the path wrong.
Here is an example of how to read out the cookie once the cookie is set:
Dim session As New notessession
Dim doc As notesDocument
Set doc = session.documentContext
dim user as variant
user = Evaluate(|@Middle(HTTP_Cookie; "user="; ";");|, doc)
print "Welcome back " + user(0) + "!"