I am having some issues with sessions.
In the first function queue
, I save the session entries
I can print this out from this function, so I can see its being set correctly.
In the function remove
, I try and save this entries session into a variable and I get the error that entries
is an undefined index
.
Does anyone have any ideas what I am doing wrong here?
function queue()
{
session_start();
$status = 'Awaiting Moderation';
$channel = '1';
// Find all entries in 'Gallery' channel with 'Awaiting Moderation' status
$this->EE->db->select('entry_id')
->from('exp_channel_titles')
->where('status', $status)
->where('channel_id', $channel);
$query = $this->EE->db->get();
$entries = $query->result_array();
$entries_count = count($entries);
// Set count
$_SESSION['entries_count'] = $entries_count;
// If entries found
if ($entries_count > 0)
{
// Flatten entry ids array
$entriesFlat = array();
array_walk_recursive($entries, function($a) use (&$entriesFlat) { $entriesFlat[] = $a; });
$entriesSerial = serialize($entriesFlat);
// Save in session
$_SESSION['entries'] = $entriesSerial;
}
}
function remove()
{
session_start();
// Get session data + save into variable
$entries = $_SESSION['entries'];
}