I want to keep a track of the pages user visited, I got to know i can do this with the help of session and hook_node_view. Being a beginner, i couldn't find any particular help on using session API, can anyone help?
1 Answer
if you just want to track user visiting there are some modules ready for that like user visits .
or if you want to do something and need to write a module for that then hook_node_view will fire when user is viewing a node . you can implement it like below :
function YOURMODULENAME_node_view($node, $view_mode, $langcode)
{
global $user; //user data is here
}
now you can do what you want with user.
-
Not exactly what i wanted. i know about hook_node_view(), how to implement $_SESSION in it or some other session tracking way. Commented Jun 17, 2015 at 14:07
-
I don't recommend you to deal with $_session . drupal has two functions _drupal_session_read and _drupal_session_write , but this two functions are for drupal internal uses , if you persist using $_session then you can install Rules Session Variable (drupal.org/project/rules_session_vars) which allow you to deal with session as variables but my sugesstion is to create your own database table and save logs there . Commented Jun 17, 2015 at 14:43