Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

MakeCookieID
(1 viewing) (1) Guest
ASP.NET PROGRAMS, ASP.NET DESIGN, ASP.NET CODE, ASP.NET TOOLS

ASP.NET combines Active Server Pages with the .NET Framework. This technology allows you to create dynamic web applications. ASP.NET pages work in all browsers. Best of all, ASP.NET lets you build web pages using less code than you need with classic ASP. If you’re using ASP.NET to build some applications for your website, you owe it to yourself to check out the articles in this section.
  • Page:
  • 1

TOPIC: MakeCookieID

MakeCookieID 08 Dec 2009 07:28 #45

The CookieID is a 20 character string that is very unique, serial to generate and of 0-9A-Z construction


Instructions: Good for making a reasonably short, pretty unique ID.

 
Function MakeCookieID()
'The CookieID is a 20 character string that is very unique, serial to generate
'
and of 0-9A-Z construction
Dim strOut
'The time, to the second
strOut = strOut & LeftPad(Hex(DateDiff("s", "1/1/1990", Now())), "0", 8) '
8 Digits
'The users IP
Dim arrayIP
arrayIP = Split(Request.ServerVariables("REMOTE_ADDR"), ".", -1)
strOut = strOut & LeftPad(Hex(arrayIP(0)),"0",2) & LeftPad(Hex(arrayIP(1)),"0",2) & _
LeftPad(Hex(arrayIP(2)),"0",2) & LeftPad(Hex(arrayIP(3)),"0",2)'
8 Digits
'A random number of exactly 4 hex digits, from 1000 to FFFF
strOut = strOut & Hex(Int((65535 - 4096 + 1) * Rnd + 4096)) '
4 digits
'That brings us up to 20 digits
 
MakeCookieID = strOut
End Function
 
  • mnjon
  • OFFLINE
  • CE Staff
  • Posts: 78
  • Karma: 40
CodersEngine
  • Page:
  • 1
Time to create page: 0.25 seconds