har försökt att lagra lite statistik från en sida.
I global.asax har jag den här koden
sub session_start(sender as object, e as eventargs)
Dim MyCookie1 As HttpCookie = request.cookies("al")
If Mycookie1.Haskeys = false then
Dim MyCookie As HttpCookie = New HttpCookie("al")
MyCookie.Values("Unik") = "unic"
Response.Cookies.Add(MyCookie)
Dim strsql3 As String = String.Format("update [counter] set unic = unic + 1 where id={0}", id)
dim objcmd3 as new oledbcommand(strsql3, objconn)
objconn.close
objcmd3.connection.open()
objcmd3.executenonquery()
objcmd3.connection.close()
objconn.open
End If
end sub
Jag försöker alltså skapa en cookie för att kontrollera unika besökare men jag får ett felmeddelande
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 12: dim datum as string = datetime.now.tostring
Line 13: Dim MyCookie1 As HttpCookie = request.cookies("al")
Line 14: If Mycookie1.Haskeys = false then
Line 15: Dim MyCookie As HttpCookie = New HttpCookie("al")
Line 16: MyCookie.Values("Unik") = "unic"
Source File: h:\inetpub\wwwroot\cup\global.asax Line: 14