Login script works...most of the time...

  • pompei
  • Graduate
  • Graduate
  • pompei
  • Posts: 117

Post 3+ Months Ago

But it doesn't work when someone clicks on a URL from their hotmail account and then tries to login...their password is validated, but it doesn't seem that the session variables are there anymore.

Here's the simplified code:

Code: [ Select ]
if (!$submit) {

// standard login fields and submit button
<form name="login" action="index.php" method="POST">
Email:<input type=text name=email size=25 maxlength=50>
Password: <input type=password name=password size=22 maxlength=22>
<input name='submit' type='submit' value='Login'>
</form>

}
else {

// this is where we check the user and password
$userid = validateEmailAccount($email, $password);

// if valid account, set session variables and re-direct
if ($userid) {
    session_start();
    session_register("SESSION_USERID");    
    $SESSION_USERID  = $userid;
    header("Location: loggedin.php");
}
else
 some code to reject user
  1. if (!$submit) {
  2. // standard login fields and submit button
  3. <form name="login" action="index.php" method="POST">
  4. Email:<input type=text name=email size=25 maxlength=50>
  5. Password: <input type=password name=password size=22 maxlength=22>
  6. <input name='submit' type='submit' value='Login'>
  7. </form>
  8. }
  9. else {
  10. // this is where we check the user and password
  11. $userid = validateEmailAccount($email, $password);
  12. // if valid account, set session variables and re-direct
  13. if ($userid) {
  14.     session_start();
  15.     session_register("SESSION_USERID");    
  16.     $SESSION_USERID  = $userid;
  17.     header("Location: loggedin.php");
  18. }
  19. else
  20.  some code to reject user


Is this because hotmail puts the click-on-URL within a sub-window? Does this invalidate any session variables? How can you get around this?
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

you can test to se if the page has loaded from within a frame (ie the hotmail window) and then reload the page in it's own window.

Possibly javascript:

Code: [ Select ]
if(window.parent){
  window.parent.location = window.location;
}
  1. if(window.parent){
  2.   window.parent.location = window.location;
  3. }


The window might be document but give it a whil and see what happens. Hope this helps :D
  • dr nick
  • Proficient
  • Proficient
  • dr nick
  • Posts: 263
  • Loc: Frankfurt

Post 3+ Months Ago

That should work, although a non-javascript version would simply be to put target="_top" in your form like this:

Code: [ Select ]
<form name="login" action="index.php" method="POST" target="_top">


That way, when you submit your form it will be on its own page and not in a subwindow.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

No javascript is always best :) thanks for that Dr Nick...

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.