I have the following JS code to check if a cookie name exists using a regular expression:
Code: Select all
var regX = new RegExp("\\b" + cookieName + "=([^;]*)");
var found = regX.exec(document.cookie);
Does someone have something similar? Or perhaps if you could describe the format of a cookie I could work out what sequence of characters I should be looking for to check for a value.
(I've found lots of examples that split the cookie and have used one to check the value, but this seems quite messy when a regular expression should be able to do the same thing.)
Thanks, Andy.