Title: Include Session variable on message body
Last modified: August 21, 2016

---

# Include Session variable on message body

 *  [João Paulin](https://wordpress.org/support/users/joao_paulin/)
 * (@joao_paulin)
 * [12 years ago](https://wordpress.org/support/topic/include-session-variable-on-message-body/)
 * Hi,
 * Can I include a SESSION variable just on the message body of the sent message?
 * If I put the tag [session] on the message body and include the following code
   on functions.php, would it work?
 *     ```
       function include_session($cf7) {
   
       	session_start();
       	$cf7->posted_data["session"] = $_SESSION['variable'];
   
       }
       add_action( 'wpcf7_before_send_mail', 'include_session' );
       ```
   
 * Is there a better way (a better hook) for doing this?
 * Thanks in advance,
    João.

The topic ‘Include Session variable on message body’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [message body](https://wordpress.org/support/topic-tag/message-body/)
 * [session](https://wordpress.org/support/topic-tag/session/)

 * 0 replies
 * 1 participant
 * Last reply from: [João Paulin](https://wordpress.org/support/users/joao_paulin/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/include-session-variable-on-message-body/)
 * Status: not resolved