How to pass POST data from Contact Form 7 to another subpage after submitting the form

I would like to pass data from Contact Form 7 to another subpage after submitting the form. I would like to use the POST method for this

  • I can get to this data with the wpcf7_before_send_mail filter as follows:
function cf7_data() {     $  submission = WPCF7_Submission::get_instance();     $  data = $  submission->get_posted_data();      // Here I have a variable containing a field from the contact form     $  subject = $  data['your-name'];      // I don't know what to do next } add_action('wpcf7_before_send_mail', 'cf7_data'); 
  • I can make redirect after submit form as follows:
document.addEventListener( 'wpcf7mailsent', function( event ) {     location = 'https://samewebsite/subpage'; }, false ); 

but I can’t figure out how I can pass and read the $ subject variable on the subpage after the redirection