URL: http://example.com/?a=1&b=2&c=3?reco_id=xxxx
xxxx is the actual value (transaction number).
- set a cookie "xxxx"
- move oder page > call "reco_id"
URL: http://example.com/?a=1&b=2&c=3?reco_id=xxxx
xxxx is the actual value (transaction number).
You could access the query part of the url via document.location.search
and the cookie string via document.cookie
and modify the latter. To achieve this a cookie library like https://github.com/js-cookie/js-cookie might be helpful.
But JavaScript has no built in helpers to read individual query parameters from the complete query string. Check out this question: How to get the value from the GET parameters?
First you need to extract the cookie parameter from the URL. Unfortunately, browser JS provides no built in method to parse URLs. I prefer using jQuery.parseParams.
Then you can use document.cookie
to store the cookie value. Setting cookie in this way can be cumbersome, so you can use a library such as jQuery.cookie
Then you can do something like this:
var params = $.parseParams(document.location.search);
$.cookie('reco_id',params['reco_id']);
Additional resources: