Dear All,
I am new to Java and Java Script.
I have a need to read a cookie and update the expiry date on a particular cookie; so I have written the following;
function Update_Cookie(){
// Write a set of cookies
document.cookie = "Session_Tolken=123"
document.cookie = "First_name=Shad"
document.cookie = "Second_name=Mortazavi"
// Script
var expireDate = new Date
expireDate.setSeconds(expireDate.getSeconds()+60)
var cookieName
var cookieValue
IfaceCookie = document.cookie.split(";")
document.write (IfaceCookie + "<BR>")
for (var i = 0; i < IfaceCookie.length; i++)
{
var cookieName = IfaceCookie.split("=")[0];
var cookieValue = IfaceCookie.split("=")[1];
document.write ("i = "+i+" CookieName ="+cookieName +"<BR>")
if (cookieName == 'Session_Tolken')
{
alert ('in')
document.cookie = "Session_Tolken="+cookieValue+";expires="+expireDate;
}
}
}
This works if the cookies are writtent in the order specified above, it breaks if I change the order in which the cookie is written?
document.cookie = "First_name=Shad"
document.cookie = "Session_Tolken=123"
document.cookie = "Second_name=Mortazavi"
The stange think is that the write statment in the script indicates that eveything is OK;
First_name=Shad, Session_Tolken=123, Second_name=Mortazavi
i = 0 CookieName =First_name
i = 1 CookieName = Session_Tolken
i = 2 CookieName = Second_name
I'm sure I am missing something obvious.
I am new to Java and Java Script.
I have a need to read a cookie and update the expiry date on a particular cookie; so I have written the following;
function Update_Cookie(){
// Write a set of cookies
document.cookie = "Session_Tolken=123"
document.cookie = "First_name=Shad"
document.cookie = "Second_name=Mortazavi"
// Script
var expireDate = new Date
expireDate.setSeconds(expireDate.getSeconds()+60)
var cookieName
var cookieValue
IfaceCookie = document.cookie.split(";")
document.write (IfaceCookie + "<BR>")
for (var i = 0; i < IfaceCookie.length; i++)
{
var cookieName = IfaceCookie.split("=")[0];
var cookieValue = IfaceCookie.split("=")[1];
document.write ("i = "+i+" CookieName ="+cookieName +"<BR>")
if (cookieName == 'Session_Tolken')
{
alert ('in')
document.cookie = "Session_Tolken="+cookieValue+";expires="+expireDate;
}
}
}
This works if the cookies are writtent in the order specified above, it breaks if I change the order in which the cookie is written?
document.cookie = "First_name=Shad"
document.cookie = "Session_Tolken=123"
document.cookie = "Second_name=Mortazavi"
The stange think is that the write statment in the script indicates that eveything is OK;
First_name=Shad, Session_Tolken=123, Second_name=Mortazavi
i = 0 CookieName =First_name
i = 1 CookieName = Session_Tolken
i = 2 CookieName = Second_name
I'm sure I am missing something obvious.