tedteeter
09-16-2013, 03:01 AM
Greetings, September 15th, 2013
Usually I use php to retrieve cookies, however, Javascript, was decided to be more convenient while the results were to be utilized by "Document.GetelementbyId" I have used the simple javascript getCookie" which didn't work! After some tinkering I elected to use php and pass the value to javascript but even my php cookie routine didn't return the cookie as it usually does?? I then resorted to an example at "W3schools" with the below! It passes fine an the alert reports "Null" I have checked and the cookie was written while there are others from my same domain and they retrieve fine?.......Additionally, I just attempted to see the value string of the cookies and it only listed a few of the cookies and not all....any ideas? Below is the latest attempt!
Appreciatively,
function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
alert(c_value);
return c_value;
}
}
Usually I use php to retrieve cookies, however, Javascript, was decided to be more convenient while the results were to be utilized by "Document.GetelementbyId" I have used the simple javascript getCookie" which didn't work! After some tinkering I elected to use php and pass the value to javascript but even my php cookie routine didn't return the cookie as it usually does?? I then resorted to an example at "W3schools" with the below! It passes fine an the alert reports "Null" I have checked and the cookie was written while there are others from my same domain and they retrieve fine?.......Additionally, I just attempted to see the value string of the cookies and it only listed a few of the cookies and not all....any ideas? Below is the latest attempt!
Appreciatively,
function getCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
c_value = unescape(c_value.substring(c_start,c_end));
}
alert(c_value);
return c_value;
}
}