Sorry, I do not understand you.
Step by step, SMF2 default config without mods (ex == for example):
1. If user agent don't send session cookie, internal links on received page contains session param.
Session cookie and session param names by default is PHPSESSID
ex: requested page from sitemap, or by external page -
http://www.simplemachines.org/community/index.php?topic=470299.02. Meta-tag rel="canonical" (if present on a page) also contains session param
ex:
<link rel="canonical" href="http://www.simplemachines.org/community/index.php?P=cf91a244cd05cf05c92009be72760d95&topic=470299.0" />
3. Thus, we obtain two different addresses.
4. If we clean up the cookies and repeat steps, we obtain a new canonical address for the same page
ex:
<link rel="canonical" href="http://www.simplemachines.org/community/index.php?P=78ea941eb4195ca54bf601a21a348553&topic=470299.0" />
You can see this situation in real browser or in serverside software (API, gateways, agregators, etc...)
PS can I see your forum url? Or examples links with "Did not work the above code." Сan be a private message.