Re: [Haserl-users] cookie creation with haserl
Brought to you by:
nangel
|
From: Ralph S. <ra...@ne...> - 2019-02-24 01:12:29
|
Hi Daniel, >Hello, I start with shell and haserl. I am looking for three days to >create a cookie shell without using javascript. > >If someone can help me by explaining how to do it, I will be happy to >deepen my knowledge. I'm not quite sure what you mean by "cookie shell". Can you explain? In general, there are two parts to using cookies: 1) creating the cookie 2) retrieving the cookie in later requests Regardless of which programming language you use, cookies are transferred the same way: as part of the HTTP protocol. I would recommend the Mozilla developer documentation as a good reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies In a Haserl script, you create a cookie by including "Set-Cookie" in the HTTP headers. An example would be: #!/usr/bin/haserl Content-type: text/html Set-Cookie: foo=bar <html><body> <h1>heading</h1> </body></html> Later on, in a subsequent request, you can obtain the value of the cookie using the variable $COOKIE_foo. #!/usr/bin/haserl Content-type: text/html <html><body> <p>Cookie value is <% echo $COOKIE_foo %>.</p> </body></html> Note that in both cases, the HTTP headers should really be using CR+LF line termination. See the section "RFC-2616 conformance" of the haserl manual at http://haserl.sourceforge.net/manpage.html for details. Regards, Ralph |