[Overview][Constants][Procedures and functions] | Reference for unit 'pwumain' (#powtils_main) |
Source position: pwumain.pas line 83
function SetCookie( |
const name: String; |
const value: String |
):Boolean; |
Like web headers, cookies must be set before any output. Use this function prior to functions such as templateout, outln, webwrite, etc.
To unset a cookie, use the UnsetCookie function.
To get (retrieve) the cookie value at a later time, use the GetCookie function.
The function returns TRUE on success, FALSE on error.
If output_buffering in your config file is disabled, this call is valid only before any output calls (outln, webwrite, templateout, etc.).
begin SetCookie('foo', 'bar'); s := GetCookie('foo'); webwrite('What is the cookie value: '); webwrite(s); end.
If you wanted to store state for say 15-90 days it is recommended you use cookies rather than sessions, usually (but rules can be broken..). The users computer should still have the cookie assuming he did not delete it. Cookies are somewhat more secure than sessions for longer periods of time (although again, this is debatable).