Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
7e46a249
Commit
7e46a249
authored
Jul 14, 2021
by
Pål Hermunn Johansen
Committed by
Poul-Henning Kamp
Aug 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docfix for issue 3634
Fixes: #3634
parent
556007bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
vmod_cookie.vcc
vmod/vmod_cookie.vcc
+33
-2
No files found.
vmod/vmod_cookie.vcc
View file @
7e46a249
...
...
@@ -150,8 +150,7 @@ Example::
$Function STRING get(PRIV_TASK, STRING cookiename)
Get the value of ``cookiename``, as stored in internal vmod storage. If
``cookiename`` does not exist an empty string is returned.
Get the value of ``cookiename``, as stored in internal vmod storage.
Example::
...
...
@@ -161,6 +160,38 @@ Example::
std.log("cookie1 value is: " + cookie.get("cookie1"));
}
If ``cookiename`` does not exist, the `NULL` string is returned. Note
that a `NULL` string is converted to an empty string when assigned to
a header. This means that the following is correct::
if (req.http.Cookie) {
cookie.parse(req.http.Cookie);
set req.http.X-tmp = cookie.get("a_cookie");
} else {
set req.http.X-tmp = "";
}
if (req.http.X-tmp != "") {
// do something with the X-tmp header...
} else {
// fallback case
}
However, using `cookie.isset()` is often a better way to check if a
particular cookie is present, like this::
unset req.http.X-tmp; # unnecessary if no fallback is needed
if (req.http.Cookie) {
cookie.parse(req.http.Cookie);
if (cookie.isset("a_cookie")) {
set req.http.X-tmp = cookie.get("a_cookie");
# do something with the X-tmp header...
}
}
# if necessary, do something when a_cookie is not there
if (!req.http.X-tmp) {
# fallback case
}
$Function STRING get_re(PRIV_TASK, REGEX expression)
Get the value of the first cookie in internal vmod storage that matches
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment