Jump to content

cookie


abdelelbouhy

Recommended Posts

hello guys i'm trying to read cookies and here is the functionfunction getCookie(searchName){ var cookies = document.cookie.split(';'); for(var i=0; i < cookies.length;i++){ var cookieCrumbs = cookies.split('='); var cookieName = unescape(cookieCrumbs[0]); var cookieValue = unescape(cookieCrumbs[1]); if(cookieName == searchName){ return cookieValue; } } return false; }the problem is when i run it the first time for example to get the userName it return the value and it's right but when i change the cookie name it return false i checked the names and the values of the cookies using alert and it shows they are there for example cookie nam age it's there but whe i seach for it getCookie('age') it return false only the first cookie(userName) returns its valueplease help

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...