Jump to content

set session variable with a link?


Jalz

Recommended Posts

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

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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.