0

Here,I am doing email verification through gmail. When I click on verify link then it redirect to the intended page ,but fail to maintain the flash data.I want that if anyone click on the click then it goes the pages and after verification it shows to the user that "Your email has been Confirmed". I need to know that how to maintain the flash data after page redirection from gmail.

public  function sendMail()
{
    $this->session->keep_flashdata('message');

$data=$this->uri->segment(2);
if($this->home_model->email_verify($data)){
    $this->session->set_flashdata('message','Your Email address has been confirmed');
    redirect('home/login','refresh');
}
else
{
    $this->session->set_flashdata('message','Something Went wrong');
    redirect('home/login','refresh');
}

}

Sunny Singh
  • 13
  • 1
  • 6

2 Answers2

0

Flashdata works between two pages on the server. So you should follow another way to verify your users. 1. Firstly you should create a column in user table. (may be 'verified'). 2. Before sending email to user's email you can declare a temporary variable. ex. $status = rand(0,9999); 3. Update the variable value to verified column. 4. Attach the variable at the end of the clicking url. ex. http://domain.com/verifyemail/email-here-as-encrypted/$status 5. Check if the email and $status value exist in the same row. 6. If it matches display your messege "Email verified". 7. Otherwise display "Cannot verified".

Try and inform. Take care.

//Data to match
$dbverified = //Get the database verified column value
$urlstatus = //url value you sent with email same as database data you update.

//Email to match
$urlemail = //decode url email
$dbemail = //Get user email from db

if($$dbverified == $urlstatus && $urlemail == $dbemail){
    echo 'E-mail verified';
}else{
    echo 'E-mail cannot be verified';
}
  • Thanks for comment. Everything working fine but the problem is that whenever i click on the link like you mentioned on step 4.It does not display the message. I am using session flash to show the message. – Sunny Singh Aug 10 '16 at 12:58
  • No session should use for the purpose. You only send url with decoded email and a value which you update into database and then in verifyemail.php page follow these step as in code. – Shafiul Bashar Aug 12 '16 at 08:41
0

Session does not work when url change

like if your url change to http://example.com to https://example.com. Flash data does not work in this. Url must be same when doing redirect.

Sunny Singh
  • 13
  • 1
  • 6