|
Function No.4
This fourth function will get variables from forms and/or querystrings,
and write them to the client as a cookie. This is often a method
used for storing variables (Not my preference)
Online applications that store lots of cookies will benefit from this function.
Usage:- Call Writecookies(StrType, IGNORELIST)
Where 'StrType' is a string value of either, "form",
"querystring", or "all"
and 'IGNORELIST' is a comma seperated string of field names to ignore.
(Case INsensitive)
EXAMPLE:- To write a cookie of all values submitted to the
page via a form.
<% Call WriteCookies("Form","") %>
ALL COOKIES WILL EXPIRE AFTER 60 DAYS, You may change this setting below.
If you wanted to exclude a field for whatever reason, then follow the example
as for the 'IncludeHidden' function.
<%
Function WriteCookies(StrType, IGNORELIST)
If lcase(StrType) = "form" or lcase(StrType) = "all" then
For each Field in Request.Form
If NOT Onlist(Field, IGNORELIST) Then
Response.Cookies(Field)=Request.Form(Field)
Response.Cookies(Field).Expires = now() + 60
'Set the cookie to expire 60 days from now
End If
Next
End if
If lcase(StrType) = "querystring" or lcase(StrType) = "all" then
For each Field in Request.QueryString
If NOT Onlist(Field, IGNORELIST) Then
Response.Cookies(Field)=Request.QueryString(Field)
Response.Cookies(Field).Expires = now() + 60
'Set the cookie to expire 60 days from now
End If
Next
End if
END Function
%>
Function No.5
This function is needed by the other functions, and must also be included in any files
which use the IncludeHidden, WriteQuerystring and WiteCookies Functions.
Function Onlist(StrField,StrIgnoreList)
TheArray=Split(StrIgnorelist,",")
If isarray(TheArray) Then
For count=LBound(TheArray) to UBound(TheArray)
If lcase(StrField) = lcase(TheArray(Count)) Then
Onlist=True
End If
Next
End If
End Function
|