Categories
ASP VBscript

Freebie: Handy VBscript Nonce Script

Here’s a handy snippet to help you keep your VBscript forms secure. (If you’re ever using vbscript for any reason)

<%

Session("last_nonce") = Session("current_nonce")

sent = Request.Form("current_nonce")
valid = Session("last_nonce")

max=100000
min=1
Randomize

Session("uwbkst_nonce") = "n"&(Int((max-min+1)*Rnd+min))

%>

And then, somewhere in your form, include

<input type="text" name="uwbkst_nonce" value="<%=Session("uwbkst_nonce") %>">

And then in your form processor file


<% If sent = valid Then
' do something
End If %>