thats kinda a fix for a problem that doesn't exist
your solution is good. your solution is so good that php already uses it. 🙂
php should already store a cookie with the session id in it... and use that cookie
look in your php.ini file... you should be able to set properties about the cookie php uses to store the session id in..
; The path for which the cookie is valid.
session.cookie_path = /
; The domain for which the cookie is valid.
session.cookie_domain =
you could just set those in your php.ini and then you don't need to put in your extra script on each page since php takes care of it for you.