<yo******@gmail .comwrote in message
news:11******** **************@ p15g2000hsd.goo glegroups.com.. .
Hi,
I have the following script
<%@LANGUAGE=Jav ascript%>
<%
var myClass = new LoginInfo();
myClass.session ID = "1321312131 ";
Response.Cookie s("testingCooki es") = myClass;
var recievedCookies = new LoginInfo();
recievedCookies = LoginInfo(Respo nse.Cookies("te stingCookies")) ;
Response.Write( recievedCookies .sessionID);
Response.End();
function LoginInfo()
{var sessionID;}
%>
How to make it work?
Cheers
You need to enable your object to serialise and deserialise the state of the
object to a string.
For example (by no means a complete implementation and is air code). :-
function LoginInfo(vsSta teIn)
{
var moState = vsStateIn ? eval(vsStateIn) : {}
vsStateIn = null
this.getSession ID = function() { return moState.session ID; }
this.putSession ID = function(value) { moState.session ID = value; }
this.serialise = function()
{
var sState = '{'
for (var key in moState)
{
if (sState.length 1) sState += ', '
if (typeof(moState[key]) == 'string')
sState += key + ": '" + moState[key].replace(/([\\|\'])/g,
'\\$1') + "'"
else
sState += key + ": " + moState[key].toString()
}
sState += '}'
return sState
}
}
To store the object:-
var oLogin = new LoginInfo()
oLogin.putSessi onID("132131213 1")
Response.Cookie s("testingCooki es") = oLogin.serialis e() ;
To retrieve the object:-
var oLogin = new LoginInfo(Reque st.Cookies("tes tingCookies").I tem)
if (oLogin.getSess ionID == "1321312131 ")
{
//is logged on
}
For further Ideas google JSON