Skip to content
Advertisement

URL set as Cookie Value Not Encoding Properly

I am trying to save a URL as the value inside a web browser cookie.

The URL is: https://www.instructables.com/json-api/getIbleStats?id=EVHUTKMJ4OFY92W

I get URL input using this code:

JavaScript

I set cookie using this PHP code:

JavaScript

And here’s the outputted cookie. It’s missing part of the URL: -api%2FgetIbleStats%3Fid%3DEVHUTKMJ4OFY92W

Advertisement

Answer

I solved it by re-encoding the URL before setting it as the cookie value:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement