php Sessions and last 5 page id's
-
Hi there
Just attempting to store and use the last 5 page id’s in a session. Being new to it I’m stuck and can only get it to print the current page id. ie it’s not storing the previous ones in the array. Am I doing something obviously wrong
global $wp_query; $post=$wp_query->get_queried_object(); session_start(); is_array($_SESSION["last_5_urls"]) or $_SESSION["last_5_urls"] = array(); $_SESSION["last_5_urls"][] = $post->ID; // This appends it right onto an array. $_SESSION["last_5_urls"] = array_slice($_SESSION["last_5_urls"], -5); Print_r ($_SESSION["last_5_urls"]);
Any pointers appreciated. Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘php Sessions and last 5 page id's’ is closed to new replies.