Jalz Posted February 15, 2010 Share Posted February 15, 2010 Hi Guys, Is it possible to set a session variable within the <a> tag link. I've started my session easlier on in my code, I am just trying to setup a variable when clicking on the edit link, but doesnt seem to be working. Any help advice would be much appreciated. <a href="myAddressEdit.php"<?php $_SESSION['-recid'] = $Address_row->getRecordId(); ?>>test</a> Thanks Jalz Link to comment https://forums.phpfreaks.com/topic/192185-set-session-variable-with-a-link/ Share on other sites More sharing options...
jl5501 Posted February 15, 2010 Share Posted February 15, 2010 if I understand you correctly, you would need to do this $_SESSION[-recid'] = $Address_row->getRecordId(); <a href="myAddressEdit.php?id="<?php echo $_SESSION['-recid']?>">test</a> Link to comment https://forums.phpfreaks.com/topic/192185-set-session-variable-with-a-link/#findComment-1012840 Share on other sites More sharing options...
Jalz Posted February 15, 2010 Author Share Posted February 15, 2010 Thanks JL5501, What you say is correct, however with your method, I setup the session['-recid'] before I click on the link. Unforutniately, I may have quite a few records on display, all with different -recids, so Im trying to create a session['recid'] = $Address_row->getRecordId(); only when the user clicks on a test link. Jalz Link to comment https://forums.phpfreaks.com/topic/192185-set-session-variable-with-a-link/#findComment-1012869 Share on other sites More sharing options...
jl5501 Posted February 15, 2010 Share Posted February 15, 2010 you cant do that without an ajax callback to the server. dont forget, php code runs on the server (not in the browser) and sends html to the browser. The only ways php can respond to a click, is if a new page loads, or if the click calls some php code via ajax. Link to comment https://forums.phpfreaks.com/topic/192185-set-session-variable-with-a-link/#findComment-1012872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.