Adding a custom Token so i can use in Webforms I am having the smart-ip module installed. It allows me to get User country, city etc very easily like this:

echo $_SESSION['smart_ip']['location']['country_code'];


I want to use this as a token replacement in webforms field. But I have no idea how to do it.
Got confused after googling. I should do the hooking in template.php? How do i do it? :/
Create your own tokens! 

You could create a small module that implements the token hooks (D6, but D7 should be similar), like so:

function YOURMODULE_token_list($type = 'all') {
  $list = array();

  $list['smart-ip']['smart-ip-country-code'] = t("The Country code");
  // ...etc

  return $list;
}

function YOURMODULE_token_values($type, $object = NULL, $options = array()) {
  $tokens = array();

  $tokens['smart-ip-country-code'] = $_SESSION['smart_ip']['location']['country_code'];
  // ...etc

  return $tokens;
}


Or, even better, add these hooks to the smart_ip.module file and submit a patch to the module maintainer :-). Tokens are really great, and it would certainly be a good addition to the smart_ip module.