Except now it'll also match any cookies with names
ending in "portfoliosec".
If JS had a decent regex engine, you'd just use a lookbehind instead (?<=^|;) but it doesn't so that wont work.
Next best solution is probably splitting and looping:
FoliosecCookie = getCookie('foliosec');
function getCookie( Name )
{
for ( CurCookie in document.cookie.split(';') )
{
var KeyValue = CurCookie.split('=',2);
if ( KeyValue[0] == Name )
return KeyValue[1];
}
return '';
}
You may need to use decodeURIComponent on the return value.
And for anyone wondering why the browsers don't just provide a built-in getCookie method that accepts a name and returns the value, the answer is because browser developers are fucking stupid.