How to set a session variable when a link is clicked? I have created a search block. It outputs multiple results (names) as links.
User can follow the link. How can I pass the user name into $_SESSION variable?
I tried doing this, the result shows a page not found error.
'name' =&gt; l(t($n['name']), 'edit_details' ,array('query' =&gt; array('uid' =&gt; $n['uid'])))

In hook_menu() I set $items['edit_details/%'] to array(). I passed the value into the session with $_SESSION['id'] = $_GET['uid'];.
You can do like this.

Link URL :

 'name' =&gt; l(t($n['name']),'edit_details/@uid', array('@uid' =&gt; $n['uid']))


In hook_menu() :

$items['edit_details/%user'] = array(
    'title'          =&gt; 'Lets start',
    'page callback'   =&gt; '_get_user',
    'page arguments'  =&gt; array(1),
    'access callback' =&gt; TRUE,
    'type'            =&gt; MENU_CALLBACK,
  );


In callback :
In callback function you will get complete user object, as this wild card used for user core module.

function _get_user($user) {
  $_SESSION['user_name'] = $user-&gt;name;
  //Redirect to any other page you want.
}


Thanks!