Read cookie using target profile script | Community
Skip to main content
rajarajanr71853
February 3, 2016

Read cookie using target profile script

  • February 3, 2016
  • 1 reply
  • 11792 views

Hi All,

How can i read cookie value in target profile script?

I tried to use this script "user.header('cookie')". But i don't know how to get specific cookie value.

Kindly help me.

Thank you,

Rajarajan R

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

February 4, 2016

Hi Raja,

 

You can use following code to read specific cookie:

var cookieName = 'aam_tnt';

var headerCookie = "; " + document.cookie;

var parts = headerCookie.split("; " + cookieName + "=");

  if (parts.length == 2) return parts.pop().split(";").shift(); 

 

Hope this helps

 

Rajneesh

rajarajanr71853
February 4, 2016

Hi Rajneesh,

We can't use plan JS inside Profile Script. Its throwing error if i use it. We can only use the mbox API.

I tried using user.header('cookie'),but i don't know how to get exact value of a cookie.

And i even tried with mboxFactoryDefault.getCookieManager()​.getCookie(name), its not working .

Regards,

Rajarajan R

March 10, 2016

Hi Raja,

I have also encountered a similar issue with reading cookie's in a profile script.

Were you able to find a solution?

Regards,

Rucha


The user. scripts are server side and cookies are client side.  Here is an easy example to do this:

 

http://www.testandtargeting.com/demo/cookie/

There is a function that is added to the mbox.js at the bottom and take a look what is added to the mboxCreate.