2

I've got a value stored in a cookie and I want to use it in the Query Text of a Result Source.

In the article Query variables in SharePoint Server 2013 I don't see anything obvious to try. It does mention you can use {Request.<PropertyName>} which is a value from the current http request - for example, {Request.Url}, but it doesn't say what else in the Request you can use.

Any information on what else is available in Request or any other ideas?

I'm using a cookie because I want to maintain this piece of information as the user browses the site. This information will come from a dropdown selection the user can make in the header.

0

Just a wild guess, but have you tried {Request.Cookies("MyCookie")}

  • Doesn't seem to work. If I look at the Query Text in the TEST tab of the Build Your Query dialog, {Request.Url} actually gets replaced with the URL, however {Request.Cookies("MyCookie")} doesn't get replaced with the value in the cookie and remains as {Request.Cookies("MyCookie")}. I tried {Request.Cookies["MyCookie"]} as well but no luck. – MLF Sep 15 '14 at 15:25
0

While the documentation sounds like the member will be resolved via Reflection, the acutal implementation simply calls HttpRequest.Item Method which returns:

The QueryString, Form, Cookies, or ServerVariables collection member specified in the key parameter. If the specified key is not found, then null is returned.

So you only need to have a unique cookie name that does not collide with the other sources. For example if you name your cookie "MyCookie" you can easily use a search query like:

Title:{Request.MyCookie}

I hope that helps somebody, even the question is old.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.