我有一段代码可以生成一个介于1和1000之间的随机数。然后它将该数字存储为一个会话。然后,您将收到一封电子邮件,其中包含打印到表单中的会话编号并提交,但问题在于每当您提交表单时(页面上有两个表单),它会刷新随机数并重置会话,导致您的代码无效。我怎么能阻止这个?停止会话被覆盖
下面是我目前的问题;
HTML
<form action="cantaccess.asp" method="post">
<p>Email:<input type="text" name="inputtedEmail" value="" /></p>
<input type="submit" name="submitEmail" value="submit" />
</form>
<form action="cantaccess.asp" method="post">
<p>Code:<input type="text" name="inputtedCode" value="" /></p>
<input type="submit" name="submitCode" value="submit" />
</form>
ASP
'Declares the variable for the random number which will be sent and stored
Dim uniqueCode
'initialising the randomize generator
Randomize()
'genarating a random number between 1 and 1000
uniqueCode = CInt(Int((1000*Rnd()) + 1))
'writing it out for testing purposes
response.write(uniqueCode)
'store it as a session to save the code when the form is submitted
Session("generatedCode") = uniqueCode
Session.Timeout= 1
在过去做了这样的事情,生成了一个[tag:rc4-cipher]加密的id,然后[tag:base64]对它进行了编码,因此可以通过电子邮件进行传输并且可以在URL中使用而不会被破坏,会话值刚刚获得不要削减它。 – Lankymart
它最初是一个8位数字,但我希望它是用户友好的我现在意识到这一点,我打算使用一个生成器,使用字母表中的所有字母,然后数字1-9生成一个10位数的唯一代码:) – Kieranmv95