在Cookie名称(Rails)中使用括号 [英] Using brackets in cookie names (Rails)

查看:172
本文介绍了在Cookie名称(Rails)中使用括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试写入/读取名称中包含括号的Cookie时,似乎Rails无法处理此问题。例如:

When attempting to write/read cookies that have brackets in the name, it seems like Rails can't handle this. For example:

cookies["example[]"] = "value"

这会导致Cookie名称为example%5B%5D而不是example []。类似地,如果我已经有一个名为example []的cookie设置,则似乎Rails无法通过调用 cookies.deleteexample []因为 [] 字符正在编码。

This causes the cookie name to be "example%5B%5D" instead of "example[]". Similarly, if I already have a cookie set with the name "example[]", then it seems like Rails is unable to properly delete it via a call cookies.delete "example[]" since the [ and ] characters are being encoded.

任何人都知道如何解决这个问题?

Anyone know how to fix this?

推荐答案

看起来这只能通过破解Rails核心。 Rails开发人员以这种方式实现了这一点。

Looks like this can only be done by hacking the Rails core. Sucks that the Rails developers implemented it this way.

这篇关于在Cookie名称(Rails)中使用括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆