|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Lose your application development headaches. Start developing and deploying applications with Advantage Database Server today. Download a 30-day trial for Free!
|
|
#1
|
|||
|
|||
|
ASP Cookie
When setting a cookie with asp, the underscore is being replaced by %5F. Does anyone know a way around it:
For Each x in Request.Cookies Response.Write("<p>") If Request.Cookies(x).HasKeys Then For Each y in Request.Cookies(x) Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y)) Response.Write("<br />") Next Else Response.Write(x & "=" & Request.Cookies(x) & "<br />") strString = Replace(x, "%5F", "_") Response.Write(strString & "<br />") Response.Cookies(strString) = "" ' Response.Cookies(strString).Domain = ".domain.com" ' Response.Cookies(strString).Expires = Date() - 1 Response.Write(strString & "=" & Request.Cookies(strString) & "<br /><br />") End If Response.Write "</p>" Next |
|
#2
|
|||
|
|||
|
You DON'T want that right?
Change: Code:
strString = Replace(x, "%5F", "_") To: Code:
strString = x
__________________
[Video] 7 Devastating Effects of Oil Depletion Why Beautiful Young Women Can't Marry Rich and Powerful Men Your Birthday Cake Sucks! For more interesting reads, visit IcyBlog. |
|
#3
|
||||
|
||||
|
Hi,
Can you post the output of the code ? As I don't get any "%5F" for underscore. |
|
#4
|
|||
|
|||
|
No, I want the cookie to have the underscore, not the %5F. When outputting it to the screen, it appears as the underscore. However, when looking at the cookie after it has been set in Firefox, the underscore is changed to %5F. I know Firefox can accept the underscore because I have other cookies that have it. That's why I tried the
Code:
strString = Replace(x, "%5F", "_") Thanks, |
|
#5
|
|||
|
|||
|
Please show us the code you are using to set the cookie.
|
|
#6
|
|||
|
|||
|
The cookie is set by another server. (A log in server) I just need to delete the cookie so it logs the user off. Not sure how they are setting it.
|
|
#7
|
||||
|
||||
|
Quote:
This can only be achieved if you are actually setting the Cookies... Quote:
Since you're not even setting the cookies, there's no way you can determine how the cookies are filtered. However you can replace them back like you already did. To delete a Cookie, just set the Cookie to nothing or set it to expire now. It seems to me like you got everything under control, what is your problem? Code:
For Each x in Request.Cookies
Response.Write("<p>")
If Request.Cookies(x).HasKeys Then
For Each y in Request.Cookies(x)
Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y))
Response.Write("<br />")
Next
Else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
strString = Replace(x, "%5F", "_")
Response.Write(strString & "<br />")
Response.Cookies(strString) = ""
' Response.Cookies(strString).Domain = ".domain.com"
' Response.Cookies(strString).Expires = Date() - 1
Response.Write(strString & "=" & Request.Cookies(strString) & "<br /><br />")
End If
Response.Write "</p>"
Next
|
|
#8
|
|||
|
|||
|
The cookie that is being set is say:
_the_cookie When I try to delete it, it sets it as %5Fthe%5Fcookie I need a way to delete _the_cookie, but I can't because it is creating a new cookie instead. |
|
#9
|
|||
|
|||
|
Try this:
Code:
For Each x in Request.Cookies
Response.Write("<p>")
If Request.Cookies(x).HasKeys Then
For Each y in Request.Cookies(x)
Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y))
Response.Write("<br />")
Next
Else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
strString = Replace(x, "%5F", "_")
Response.Write(strString & "<br />")
Response.Cookies(strString) = ""
' Response.Cookies(strString).Domain = ".domain.com"
Response.Cookies(strString).Expires = Date() - 1
Response.Write(strString & "=" & Request.Cookies(strString) & "<br /><br />")
End If
Response.Write "</p>"
Next
|
|
#10
|
||||
|
||||
|
Hi,
As the cookies are not set by you, there maybe more similar case for other special characters. e.g. @%&^ I would suggest you use unescape Code:
strString = unescape(x) Hope it helps |
|
#11
|
|||
|
|||
|
Tried both suggestions, same results. Any other ideas?
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > ASP Cookie |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|