Subscribe to a php Session

Asked

Viewed 110 times

1

When the user accesses the property details page on my website, 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 the firing of e-mail in Hidden input, I retrieve his email in the.php email file and is sent the proposal directly to him through phpmailer.

Ex: Accessing property 3174, I will store the email of the broker x responsible for this property, if access 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 so that every time a different property is accessed, the current session is destroyed and a new one is created storing the email of the broker responsible for the property?

  • every time you set up the session, it will already reset the previous session. But you can destroy a session just like this: unset($_SESSION['corretor']).

  • @Ivanferrer, thank you very much for the collaboration, it has already been solved. Qlqer thing I am available.

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 created session, but it is not necessary because whenever you pass a new value to that SESSION it will replace the old value.

NOTE: Remove SESSION from within validation if(!isset($_SESSION['corretor'])){} because if not you will only manage to set the first time, that’s when it doesn’t exist yet.

  • is that guy didn’t need that validation. Only setting the session is gone, will reset as I change property. Vlw! Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.