Using Cookies to Set Object State
Aug 06, 2012
We needed to find a way to store user activity across sessions independent of the LMS platform for a particular course by utilizing the setting and getting of cookies to set the particular course completion state to True, and then reading it back and setting a variable that would be used to change the object state.
Here is the setter:
document.cookie = "Course1="+escape("True")+ "; expires=02/02/2013 00:00:00";
And here is the getter:
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( '(^| ?' + cookie_name + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;
}
var courseStatus = get_cookie ( "Course1" );
var player = GetPlayer();
player.SetVar("Course1",courseStatus);
Of course, it's not working. Any suggestions on the best approach, or if this is even feasible?
Be the first to reply
This discussion is closed. You can start a new discussion or contact Articulate Support.