Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Cookie Script fix

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a page with 20 potential cookies:

e.g.,

var TheCookieName = form.nameA
var TheCookieName = form.nameB

etc.

Any ideas on how I can modify this script so that it will call and display only the latest cookie?

function GetCookie (CookieName) {
var cname = CookieName + "=";
var i = 0;
while (i < document.cookie.length) {
var j = i + cname.length;
if (document.cookie.substring(i, j) == cname){
var leng = document.cookie.indexOf (&quot;;&quot;, j);
if (leng == -1) leng = document.cookie.length;
return unescape(document.cookie.substring(j, leng));
}
i = document.cookie.indexOf(&quot; &quot;, i) + 1;
if (i == 0) break;
}
return &quot;*&quot;;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top