One day one of my clients came to me and asked me to integrate login with Google Oauth system. I said ok I will do it.
I created the system and system was working fine but there was a bug. When google authorize my request and redirect me back to my Google login page, where I placed a code to header redirect the user from Google login page to the home page, during the redirection it appends #_=_ in URL itself.
I dig back in the code and tried to find some clue why this is happening but did not find any clue and I was unable to remove #_=_ from URL.
I searched for this bug but could not get success. Then I search on internet for other websites if they facing same problem and I found yes some website have same issue. Suddenly I got a trick in my mind and it worked. I am going to show you what is it and how it works.
Instead of header redirect just print below script:
I created the system and system was working fine but there was a bug. When google authorize my request and redirect me back to my Google login page, where I placed a code to header redirect the user from Google login page to the home page, during the redirection it appends #_=_ in URL itself.
I dig back in the code and tried to find some clue why this is happening but did not find any clue and I was unable to remove #_=_ from URL.
I searched for this bug but could not get success. Then I search on internet for other websites if they facing same problem and I found yes some website have same issue. Suddenly I got a trick in my mind and it worked. I am going to show you what is it and how it works.
Instead of header redirect just print below script:
google_login.php
echo '<script type="text/javascript">window.top.location.href="http://mygreatsite.com/home.php"</script>';
Here I am redirecting the user by top.location. instead of header()
I hope it will also help you. Good luck...
Note:
You can also redirect user by HTML <meta>. According to some developers it also works as well.
I hope it will also help you. Good luck...
this worked for me. thanks
ReplyDeleteThank you Vivek, I hope other tutorials will do same for you.
Delete