在Wordpress post url中传递会话值

I have a post in wordpress.

[insert_php] 


$_SESSION[ref_no] =1001;


global $wpdb;
$query = $wpdb->get_var("SELECT name FROM table_reg WHERE ref_no = $_SESSION[ref_no]");
echo $query;

[/insert_php]

This post have an URL:http://localhost/wp/?p=123

What i want is, when an user data is stored in a database table from a form, a message need to generate as an email using wp_mail() with the above url to the user, from which user can download the above "post" data as pdf using the session variable as ref_no . I was lacking in generating pdf file from the url.

I have tried to write the code below for that.But failed.

[insert_php]
$_SESSION[ref_no] =1001;
$dateTime=date('Y-m-d H:i:s');
$multiple_to_recipients = array(user@eg.com);
$subject = 'You Have registered for DATA on '. $dateTime ;

$message = "Download your registration details by clicking this link: http://localhost/wp/?p=123
";
$message .= "Email Us:admin@eg.com 
";

$headers = array(
'From: admin@eg.com'

);  

wp_mail( $multiple_to_recipients, $subject, $message, $headers );
[/insert_php]

Please help me.