Subscribe to a php session

1

When the user accesses the details page of the property on my site, I need to store the broker's email in a session, and when he sends the proposal form, the broker's email is sent to the file responsible for triggering email in input hidden, I retrieve his email in the email.php file and is sent the proposal straight to him through phpmailer.

Ex: Accessing the property 3174, I will store the email of the broker x responsible for this property, if access to another property destroys the previous session and creates a new one with the email of the broker of the current property.

//Aqui eu crio a session['corretor']
if(!isset($_SESSION['corretor'])){
    echo $_SESSION['corretor']=$results['email'];
}

How do I make sure that every time a different property is accessed, the current session is destroyed and a new one is created by storing the email of the broker responsible for the property?

    
asked by anonymous 25.08.2015 / 21:47

1 answer

3

On the property page where you arrow the value of SESSION put in the line above:

unset($_SESSION['corretor']);

This will destroy the session created, but it is not necessary because whenever you pass a new value to this SESSION it will replace the old value.

NOTE: Remove the SESSION from within the validation if(!isset($_SESSION['corretor'])){} because otherwise you will only be able to set the first time, which is when it does not yet exist.

    
25.08.2015 / 22:50