Guest Posted September 19, 2002 Posted September 19, 2002 I'm trying to modify my user tracking module that I developed last week to be able to not only show how users tracked through the site, but also the original referring URL they originated from. To do this, when a session is first created for a new user, I need to session_register the HTTP_REFERER. However, after looking at the session code here for about an hour, I can't find where a new session is created for clients w/o sessions. The logic for OSC is (this is by deduction, I can't find this in the code): 1) User loads a OSC store w/o a session from a referring URL 2) OSC creates a session ID for that user that allows various parts of the program to session_register variables (like $cart) to the user All I want to do is session register HTTP_REFERER DIRECTLY after the user comes to the site for the first time. To make sense of sessions.php is outside of my brain, especially since it supports MySQL, flat file, php3 and php4 functionality that is NOT WELL DOCUMENTED!! :) So, if a developer can help me choose the right place to session_register this referring url, I'd appreciate it. Thanks! Andrew
mattice Posted September 20, 2002 Posted September 20, 2002 To make sense of sessions.php is outside of my brain, especially since it supports MySQL, flat file, php3 and php4 functionality that is NOT WELL DOCUMENTED!! :)So, if a developer can help me choose the right place to session_register this referring url, I'd appreciate it. Thanks! Andrew The session is checked/created in application_top.php: // lets start our session if ($HTTP_POST_VARS[tep_session_name()]) { tep_session_id($HTTP_POST_VARS[tep_session_name()]); } if ( (getenv('HTTPS') == 'on') && ($HTTP_GET_VARS[tep_session_name()]) ) { tep_session_id($HTTP_GET_VARS[tep_session_name()]); } if (function_exists('session_set_cookie_params')) { session_set_cookie_params(0, substr(DIR_WS_CATALOG, 0, -1)); } tep_session_start(); So I guess calling session_register('your_refer', $HTTP_REFERER); right after the session_start() should do it. HTH, Mattice "Politics is the art of preventing people from taking part in affairs which properly concern them"
Guest Posted September 20, 2002 Posted September 20, 2002 Mattice, Notice how session_start is called for ALL includes of application_top.php, it's not nested in any "is this a new user" logic. I'm looking for the EXACT place where OSC realizes that the user is a NEW user and opens a new session ID. Try looking at the includes/classes/sessions.php, it's a tough file because there is ZERO documentation on how it handles php3, php4 and mysql. If a developer can please point me to the logic where OSC realizes there is a new user loading a page in the session, I'd appreciate it. andrew
Ian Posted September 20, 2002 Posted September 20, 2002 It's my understanding that session_start checks for the existence of a cookie or url session_id. If either exist the previous session resume else a new session is started. These checks are carried out by php itself (at least in v4+) You could carry out the tests yourself. However would it not be easier to check whether the shop domain is the same as http_referrer domain. If not then they've come from somewhere else! Trust me, I'm an Accountant.
Guest Posted September 20, 2002 Posted September 20, 2002 Ian, Your suggestion is my fallback method. I'm still one that believes in saving CPU cycles, so finding the exact moment of discovery of a new user session would just piggy back on previously performed logic. You also confirmed my suspicion that there is a weird symbiotic relationship between the PHP code in sessions.php and the php3/4 code that is hidden from view. In that case, your suggestion might be all that is left to me. Thank god there is URL parsing logic handy in the TEP code :) Andrew
Recommended Posts
Archived
This topic is now archived and is closed to further replies.