dflow Posted November 30, 2008 Share Posted November 30, 2008 here is what i want to achieve: i want to get ref_id and store it as a session variable and if the user reaches the contact form to store the session variable as a value. for example: mysite.com?ref_id=test i understand i need to start a session and to $_GET it form the url how would you approach it? Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/ Share on other sites More sharing options...
Mchl Posted November 30, 2008 Share Posted November 30, 2008 Like here Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-702243 Share on other sites More sharing options...
dflow Posted November 30, 2008 Author Share Posted November 30, 2008 thx ill get into IT! Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-702248 Share on other sites More sharing options...
dflow Posted December 1, 2008 Author Share Posted December 1, 2008 OK this is a test code <?php session_start(); // store session data $_SESSION['affid']=$_GET['affid']; ?> <html> <body> <?php //retrieve session data echo "affid=". $_SESSION['affid']; ?> <a href="http://XXXX.com/Contact.php">go to CONTACT</a> </body> </html> i get the the affid from the URL parameter it is echoed the problem is that when i want to echo it on the next page i get nothing. if the the session is stored why is it not retrieved ? Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-702989 Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Because you're overwriting it with empty variable Change $_SESSION['affid']=$_GET['affid']; to if (isset($_GET['affid'])) { $_SESSION['affid']=$_GET['affid']; } Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-702993 Share on other sites More sharing options...
dflow Posted December 1, 2008 Author Share Posted December 1, 2008 still not echoed on the next page Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-703003 Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 How does the next page look like? Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-703005 Share on other sites More sharing options...
dflow Posted December 1, 2008 Author Share Posted December 1, 2008 just an echo testing page <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <?php echo $_SESSION['affid']; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-703010 Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Add session_start(); at the beginning. Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-703019 Share on other sites More sharing options...
dflow Posted December 1, 2008 Author Share Posted December 1, 2008 fundamentals!!! thank you for your patience Link to comment https://forums.phpfreaks.com/topic/134869-solved-introduction-to-session-variables/#findComment-703028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.