Im setting a up a cookie value from server side in a button event as follows.
Private Sub btn_set_Click(sender As Object, e As EventArgs) Handles btn_set.Click
Dim myCookie As HttpCookie = New HttpCookie("downloadToken", "sandeep")
myCookie.Expires = Now.AddDays(1)
myCookie.Secure = False
myCookie.HttpOnly = True
Response.Cookies.Add(myCookie)
End Sub
But when I check the value of downloadToken from clientside using JQUERY Cookie plugin, it returns undefined.
Cookies.get("downloadToken"); //returns undefined
Immediately after Response.cookies.add, there is a file download code. That is actually sending file to the client for downloading.
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileInfo.Name)
Response.AddHeader("Content-Length", FileInfo.Length.ToString())
Response.AddHeader("Connection", "Keep-Alive")
Response.ContentType = “application/octet-stream”
Response.ContentEncoding = Encoding.UTF8
Response.TransmitFile(FileInfo.FullName)
Response.Flush()
Response.End()
May I know Whats wrong in my code?