Yihung,
Try reading a couple tutorials on sessioning and session variables. It looks to me as if that's how the site you used as an example is handling that feature. Basically, you set a unique identifier on a vistor (generated by PHP's session manager) when they arrive at your site. This can be done either through cookie or URL re-writing (http:/www.ncix.com/ is a good example of url re-writing though they use Cold Fusion). You then use the session id as a primary key of sorts to store info about what the visitor has requested. I realize theis doesn't really answer your question, but it might get you started in the right direction. Hope this helps!!!
Cheers,
Geoff A. Virgo