0

i have already searched but found nothing pertaining to it. I wonder how I can create a single cookie with multiple data.

My data is:

[
{
    "domain": ".example.com",
    "expirationDate": 1497384817,
    "hostOnly": false,
    "httpOnly": true,
    "name": "download_security",
    "path": "/down",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "3lsod",
    "id": 1
}
]

I am applying in PHP with:

setcookie("domain", ".example.com");
setcookie("expirationDate", "1497384817");
setcookie("hostOnly", "false");
setcookie("httpOnly", "true");

But several cookies are being created instead of one, how can I resolve this?

1 Answers1

1

You should create a single cookie and set its value to a JSON-serialized object.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964