locked
How to redirect user to dashboard after clicking on email notification? RRS feed

  • Question

  • User-859685044 posted

    Hello,

    After user has registered / email notification after clicking link, how to redirect user to his account without asking to login.

    Your help is very much appreciated.

    Tuesday, December 11, 2018 5:23 AM

All replies

  • User-2054057000 posted

    You can do these things:

    1. Generate a new Guid, and store it in the database.
    2. In the email your link should contain the same guid in the query string. 
    3. Now in your web page you should check if the guid matches then you log the user automatically to his account. 

    Explanation:

    1. You can create a new table that stores the guid and the user id
    2. Before you send the email to a user you store that guid with user id in the table. The table structure is given below:
    3. User Id Guid
      1 0f8fad5b-d9cb-469f-a165-70867728950e
    4. Now when you end the email give a login to your account link that contains the same guid in query string.
    <a href="http://www.yourwebsite.com/login/?guid=0f8fad5b-d9cb-469f-a165-70867728950e">Login to your account</a>

    So when the user clicks the link he reaches the website's login page. In that login page you extract the guid value from query string. Then you match the guid with the guid column of the table. So you get the User Id of the person. 

    Now you know which user has clicked the link and you do the automatic login. 

    Some website also adds the expiry time of the guid. For this they add a new ExpiryTime column on the table. And this helps them to prevent users to use the link for login after the exprity time has reached.

    I hope I am clear in my explanation.

    Thanks You,
    YOGI 

    Tuesday, December 11, 2018 10:29 AM