从Apache解析HTTP_COOKIES字符串以在#if子句中使用

时间:2022-06-12 16:25:48

I want to be able to read the cookies from Apache's HTTP_COOKIE string and then add includes based on the contents of that string.

我希望能够从Apache的HTTP_COOKIE字符串中读取cookie,然后根据该字符串的内容添加includes。

I've got this far:

我到目前为止:

<!--#set var="cookies" value="HTTP_COOKIE" -->
<p>COOKIES:  <!--#echo var="$cookies"--></p>

which gives me a string with all the cookies in it.

它给了我一个包含所有cookie的字符串。

Now I want to be able to parse the string for something like Name=Bob.

现在我希望能够解析像Name = Bob这样的字符串。

I thought I'd be able to do this:

我以为我能做到这一点:

<!--#if expr="$cookies = /Name=([a-zA-Z]+)/"-->
<p>Your name is <!--#echo var="$1"--></p>
<!--#endif-->

But it doesn't seem to work. What should I be doing -- or isn't this possible?

但它似乎没有用。我应该做什么 - 或者这不可能吗?

1 个解决方案

#1


This is definitely possible -- see the get_include_var function of mod_include.c.

这绝对是可能的 - 请参阅mod_include.c的get_include_var函数。

Perhaps your regular expression needs some tweaking.

也许你的正则表达式需要一些调整。

#1


This is definitely possible -- see the get_include_var function of mod_include.c.

这绝对是可能的 - 请参阅mod_include.c的get_include_var函数。

Perhaps your regular expression needs some tweaking.

也许你的正则表达式需要一些调整。