The referer header is rather unreliable, there are antivirus software and firewalls out there that filter it completely. The only thing you can pretty safely rely on are cookies and with them, sessions.
Cookies are stored on the client side, in the browser, therefore can be manipulated, but if you are storing non-critical information, they can be enough.
Sessions nowadays rely on cookies as a means of starting them. A randomly generated hash is stored in a cookie, the corresponding data is stored on the server linked to this hash. When the client requests the next page, this data is retrieved. For more information about sessions read the corresponding section of the PHP manual.
As I wrote, sessions rely on cookies nowadays and you shouldn't do that unless you are aware of the security implications. You can however use URL parameters to pass the session ID along.
On a side note: in order to use cookies (and with them sessions) both the setting and the final URL must be on the same domain. If this isn't the case, you can use request parameters to pass the information along.