Jump to content

Session variables not working


devadok

Recommended Posts

Hi,

 

I'm developing an addon and inside the hooks.php, I have the following code:

 

add_hook('AdminAreaHeaderOutput', 1, 'bnw_todo_itens');
function bnw_todo_itens($vars) {
$check = true;

// if session var exists, then check if we need to check again or not
if (isset($_SESSION['todo_list_cache'])) {
	$last_checked = $_SESSION['todo_list_cache'];
	$now = time();

	// do not check within 1 hour
	if (($now - $last_checked) < (60 * 60)) {
		$check = false;
	}
}

$adminid = $vars['adminid'];
if ($check) {
	// check if there is any pending/new todo item
	$sql = "SELECT id, title, description, duedate, `status` ";
	$sql .= "FROM tbltodolist ";
	$sql .= "WHERE admin = " . $adminid . " ";
	$sql .= "AND `status` IN ('New', 'Pending') ";
	$sql .= "AND duedate <= '" . date('Y-m-d') . "' ";
	$sql .= "ORDER BY duedate ";
	$result = mysql_query($sql);

	while (($row = mysql_fetch_assoc($result))) {
		// create html
	}

	// updates the last checked time
	$_SESSION['todo_list_cache'] = time();

	// returns the created html
	return $html;
}
}

 

When a refresh the page and try to read the session var that I have set ($_SESSION['todo_list_cache']), the variable doesn't exist. Whenever I try debugging the $_SESSION, all I see is:

 

[tkval] => Asd6a1sdfA3

[adminid] => 123

[adminpw] => 123123132123132123132123123

 

Does anyboy know what can be wrong?

 

Thanks

Edited by devadok
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated