How to set a session variable when a link is clicked?
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!