Detect url and save it in cookie

Detect url and save it in cookie

Hello

I want to detect if a user is coming from a given url. If he is, the url is stored in a cookie and a div is displayed in top of the pages when he navigates around the site.

How do I do that?
I have downloaded jquery cookie plugin