Click here to Skip to main content
16,017,707 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
I am send sending a mail with a link to click and open a webpage.
HTML
<table >
<tr><td ><a href='http://www.mywebsite.com/profile-page.php?reg_id=$r1' target='_blank' >Open Profile</a></td></tr>
</table>

By clicking this "Open Profile" i want to redirect and open a profile in the location but
in page "profile-page.php" i using session redirect if no session.

Q1- Can i pass a session value in parameter if yes then how?
Q2- How the person can see direct profile by clicking " Open Profile link"?

What happening in current.
When user click the link it redirect to home page because of this code
PHP
if(!$_SESSION['user_name'])
{

header("location:http://www.mywebsite.com/");
}
in profile-page.php.

If anyone have the solution or any suggestion pls reply.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 3-Jun-13 9:55am    
Why in URL? Why not POST parameters?
—SA
[no name] 4-Jun-13 1:59am    
Hi,
Because it is a mailer.
and link given in a mailer not in form.
Thanks

1 solution

First of all you can send session variable. you will have to embed them with your url, but you can't automatically expect that your session to get automatically.
the possible solution, as example:
HTML
<table >
  <tr>
     <td >
          <a href='http://www.mywebsite.com/profile-page.php?reg_id=$r1&username=<?=$_SESSION['user_name']?>' target='_blank'>Open Profile</a>
     </td>
  </tr>
</table>
 
Share this answer
 
Comments
[no name] 4-Jun-13 3:07am    
hi Mohibur,
Thanks buddy but do you it will work. because i donot think so.
Mohibur Rashid 4-Jun-13 3:30am    
I know what I told you. I am very much aware of my answer. But have you understand what I said?

Why do you think it won't work?
[no name] 4-Jun-13 3:38am    
Hi,
Coz i check that it redirected to home page and how the session will open in that page.
thanks
Mohibur Rashid 4-Jun-13 3:54am    
Alright, here is in detail:

Send your Session value as parameter
as example:
href='http://www.whateversite.com?session_id=<?=session_id()?>'

in your redirecting page: set
$_COOKIE['PHPSESSID']=$_GET['session_id'];
session_start();
make sure your session live long enough to be access by the email recipient.

And finally this is a bad idea. don't do it.

Create a database entry and send a certain value as data to email. when user will click the link verify it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900