Login and auto refresh a page

  • tiffix
  • Student
  • Student
  • User avatar
  • Posts: 65
  • Loc: kenya

Post 3+ Months Ago

hi, I a have a javascript window that my users will login and once logged in they are redirected to a page which i need it to be refreshed if the $_SESSION['loggedin_user'] is set to true. thanks.

here is the code preview
Code: [ Select ]
<?php
ob_start();
session_start();
if(isset($_SESSION['loggedin_user'])){
?>    
<script type="text/javascript">    
 window.location.reload('../index.php');    
 window.close();
</script>    
<?php
}
?>
  1. <?php
  2. ob_start();
  3. session_start();
  4. if(isset($_SESSION['loggedin_user'])){
  5. ?>    
  6. <script type="text/javascript">    
  7.  window.location.reload('../index.php');    
  8.  window.close();
  9. </script>    
  10. <?php
  11. }
  12. ?>


can
Code: [ Select ]
window.location.reload()
be used to reload a different page?


I need a syntax that when I press the "submit" button from a pop-up window, the pop-up window will close and the "original" page will refresh its contents ( to display contents entered in the pop-up window.) How can i do this?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I could be wrong, but I believe that if the popup window actually came from the page you are wanting to refresh then the reload command should work as it actually works on the parent I believe. The proper command to refresh a page is location.reload() or you can use location.reload(true) to force a reload even if nothing was changed.

When you create your popup window make sure you assign it a handle, so something like:

Code: [ Select ]
popup_window = window.open("");


Now once the popup window is open, and your user enters information that would be stored to your server (probably in a DB), then you want to refresh the other page using the reload command, and then close the popup window referencing the handle you did earlier like:

Code: [ Select ]
popup_window.close();


Now if you actually want to change the main window to a completely new URL you might try using something like this before closing the popup window:

Code: [ Select ]
window.opener.location.href = 'http://www.yoursite.com/newpage.html'


Another thing you can try if you are having issues with the popup window reloading the main window is by using a command such as:

Code: [ Select ]
window.opener.location.reload()


Let me know if any of this worked, and what you ended up doing. Thanks!
  • tiffix
  • Student
  • Student
  • User avatar
  • Posts: 65
  • Loc: kenya

Post 3+ Months Ago

Thanks Bigwebmaster. i ended up using this

Code: [ Select ]
<?php
ob_start();
session_start();
if(isset($_SESSION['loggedin_user'])){
?>    
<script type="text/javascript">    
 window.opener.location.reload( true);
 window.close();
</script>    
<?php
}
?>
  1. <?php
  2. ob_start();
  3. session_start();
  4. if(isset($_SESSION['loggedin_user'])){
  5. ?>    
  6. <script type="text/javascript">    
  7.  window.opener.location.reload( true);
  8.  window.close();
  9. </script>    
  10. <?php
  11. }
  12. ?>

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 73 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
 
cron
 

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