dexterz 0 Junior Poster in Training

Hello guys,

Can somone help me figure this out.

I tried for few hrs today, but still failed to meet my expectation. In old ASP, the cookie is working prefectly, and it prevent me from rating multiple times even.

It's a lot different in ASP.NET. For example, if i rate a link id=95, then I rate another link id=90. What happen is that after I rated link id=90, I can go back to link id=95 and rate it again. I set the expiration date to 7 days. The cookie should have prevented me from rating link id=95.

Below is the code to process rating:


'Code begin
Sub Page_Load(Sender As Object, E As EventArgs)

Dim intLinkID as integer
intLinkID = Request.QueryString("id")

'Create cookie
Response.Cookies("RatingLink")("Link" & intLinkID) = "True"
Response.Cookies("RatingLink").Expires = DateTime.Now.AddDays(7)

'If the user has already rated the link, then display an error message
If Request.Cookies("RatingLink")("Link" & intLinkID) = "True" Then

HttpContext.Current.Response.Write("<b>You have already rated this link. Wait for 7 days to rate this link again</b>.<br><br>Please hit your browser back button to go back to the previous page.")

HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()

End if

'SQL to insert the rating value
strSQL = "Update LINKS SET LINK_RATE = LINK_RATE + " & Replace(Request.QueryString("rateval"),"'","''") & ", NO_RATES = NO_RATES + 1 WHERE LINK_ID =" & Request.QueryString("id")

'DB connection
DBconnect()

objConnection.Open()
objCommand.ExecuteNonQuery()

'Close the db connection
objConnection.Close()

'Redirect to previous page after rating is complete
Dim urlredirect as string
urlredirect = "linkdetail.aspx?id=" & Request.QueryString("id")
Response.Redirect(urlredirect)

End Sub

Live URL of this project: http://www.myasp-net.com/directory/default.aspx

Regards,

Dexter Zafra
www.ex-designz.net