There are a few server variables that you can use, HTTP_REFERER being the most obvious, but not all that reliable. If you know what pages the user should be coming from you can check for that. Take a look at the $GLOBALS array for more info.
Sessions should be already configured if you have a standard PHP installation. You need to call session_start() before doing anything. After that variables can be added to the $_SESSION array simply by assigning them. Then in subsequent page accesses you can check for their existence. By default PHP uses file-based sessions but you can use a database with session_set_save_handler() if your feeling brave 😉
HTH