I wouldn't use IP addresses for tracking users ( or session ids based on them for that matter) as they can change between visits for returning users (for those of us on dial up accounts).
Apparently they even change between page requests for aol users due to proxys.Also with the use of proxys many users could be seen to originate from the 1 IP address.
I'd generate as session ID , fairly long and random , and store it as the key to a DB and in the cookie.
Then when the user visits lookup the key in the DB and get/set any info that you need to.