Jump to content

variable from email link to session


lightlydone

Recommended Posts

Hi All,

I'm sending an email with a link to a web page with a form on.

 

<tr style="padding:10px;">
  <td align="center">
    <a style="text-decoration:none;" href="http://www.foo.co.uk/bar.php?id=123">
      <img src="/header.jpg" border="0" style="display: block;" width="380" height="64" alt="Logo" />
    </a>
  </td>
</tr>

 

I currently GET the id from the URL and add it to a hidden field in the form which then sends the ID to the database on submit so I know from which email the user came from to fill out the form.

This doesn't always work as I guess some people move from the form page to look at other pages on my site then come back to fill in the form.

I think I need to use SESSION to keep the id 'active' but cannot figure out how to GET the id from the URL and put it into a SESSION, alas I am struggling to even start and finish a basic SESSION.

 

Thanks in advance,

Ben.

Link to comment
https://forums.phpfreaks.com/topic/229151-variable-from-email-link-to-session/
Share on other sites

At the top of ALL pages you need:

 

session_start();

 

Then on the bar.php you need:

 

session_start();
if(!isset($_SESSION['id']) && isset($_GET['id'])) {  //see if session id is not set and that get id is set
   $_SESSION['id'] = $_GET['id'];
}

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.