4 elgg.provide(
'elgg.session');
19 elgg.session.cookie =
function(name, value, options) {
20 var cookies = [],
cookie = [],
i = 0, date, valid =
true;
23 if (
elgg.isUndefined(name)) {
28 if (
elgg.isUndefined(value)) {
30 cookies =
document.cookie.split(
';');
31 for (
i = 0;
i < cookies.length;
i += 1) {
32 cookie = jQuery.trim(cookies[
i]).split(
'=');
34 return decodeURIComponent(
cookie[1]);
42 options = options || {};
44 if (
elgg.isNull(value)) {
49 cookies.push(name +
'=' + value);
51 if (options.expires) {
52 if (
elgg.isNumber(options.expires)) {
54 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
55 }
else if (options.expires.toUTCString) {
56 date = options.expires;
60 cookies.push(
'expires=' + date.toUTCString());
68 cookies.push(
'path=' + (options.path));
72 cookies.push(
'domain=' + (options.domain));
76 cookies.push(
'secure');
79 document.cookie = cookies.join(
'; ');
87 elgg.get_logged_in_user_entity =
function() {
88 return elgg.session.user;
96 elgg.get_logged_in_user_guid =
function() {
97 var
user =
elgg.get_logged_in_user_entity();
98 return user ? user.guid : 0;
106 elgg.is_logged_in =
function() {
107 return (
elgg.get_logged_in_user_entity() instanceof
elgg.ElggUser);
115 elgg.is_admin_logged_in =
function() {
116 var
user =
elgg.get_logged_in_user_entity();
117 return (user instanceof
elgg.ElggUser) && user.isAdmin();
123 jQuery.cookie =
elgg.session.cookie;
128 elgg.session.user =
new elgg.ElggUser(
elgg.session.user);
elgg session cookie
Helper function for setting cookies.
GNU GENERAL PUBLIC LICENSE June Free Software Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license document