Iam just using an iframe for login and register.
and i need to reload the page when the message appears that he successfully registered/logged-in.
for example the iframe would be
when he click login in the iframe it reload other page called "login_success" this page send message"successfully logged in".
Now is the proplem i need the browser reload the page so that the session work in the page that loads the Iframe.
Thanks for responding.
You can use following script.
window.parent.location.reload();
Here it is
document.getElementById('ifarme_id').contentWindow.location.reload();
If it is in same domain you can try below
var myframe = document.getElementById('Ifrme_id');
myframe.src = myframe.src;
Related
I'm building a plugin, but somehow when I post a form and redirect back to the page, the page is empty. Content returns after a page reload.
I use the following after the (successful) form submit.
wp_redirect(get_permalink());
exit();
I don't seem to get any errors (I do have WP_DEBUG on).
There can be cache in your browser or web server. You can try generate unique link for reload. For example add to url parameter.
$url = add_query_arg("unique", time(), get_permalink());
wp_redirect($url);
exit();
I am new to php. I have Form on a page with a button that once clicked it pops up another sub page :
onclick="newPopup('page2.php','750','500')
page2.php has another button, I want to be able to redirect the Main Page to another url using this pop-up.
How can I do this?
If you want to redirect the main page on a button click in the popup, you need to do this with JS, not PHP.
Add this to the button in the popup:
onclick="window.opener.location.href='someurl.php'";
From a popup, you can access the page/window that opened the popup with: window.opener. This means that you also can call functions on the main page: window.opener.someFunctionOnTheMainPage().
On click of button, you can execute below JavaScript:
window.opener.location.href = 'new URL';
This will redirect your parent page to the new URL.
How can I make "location.reload()" on php file without get perimeter ?
Here is an example..
Let's say I have PHP, and at the right top, I have logout button.
When user press that button, PHP will automatically re-direct to "index.php?logout" and after that, i will logout (unset cookie and other) and return ( javascript location.reload() ) to main page (login page)
Problem that I have is, when php return to login page after logout, then url is still "index.php?logout", so when user login back with "index.php?logout" page, it will automatically logout (because of ?logout perimeter on url)..
So how can I tackle this problem ? Anybody got any idea ?
I hope you all understand what i'm trying to tell you all about..
Thanks for reading this..
use self.location.reload instead of location.reload. Because location.reload reloads the current page. You can simple use
self.location.reload = index.php
Or you can remove query paramter from your url like
var url = 'index.php?logout'
url=url.split("?")[0];
location.reload =url
location.reload() reloads the current page with the post data,you should use window.location.href in case of login/logout
When user press that button, PHP will automatically re-direct to "index.php?logout" and >after that, i will logout (unset cookie and other) and return ( javascript location.reload() >) to main page (login page)
all these can be implemented in server side.
// LOGOUT
if(isset($_GET['logout'])){
//logout code
}
header('location: www.yoursite.com/login') //or whatever the url is
exit;
you re-direct to login page and save page url that request for login that is index.php?logout for re-direct back you must check perimeter logout if exist remove it from return url for example
//replace parent::$Patch with your root url like "http://localhost/myapp/"
if(!parent::$Patch.'admin/login.php'=='http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']){//check if you are in login.php page didn't redirect to login.php
if(!#header('Location:'.parent::$Patch.'admin/login.php?url='.rawurlencode(str_replace("logout","",'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])))){
//if header error echo javaScript code for re-direct
?>
<!DOCTYPE HTML>
<html>
<head>
<script language="javascript">
var LoadP = <?php print "'".parent::$Patch.'admin/login.php?url='.rawurlencode(str_replace("logout","",'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))."'"?>;
self.location = LoadP;
</script></head></html>
<?php
}
exit();
}
}
this code re-direct user to login page and keep return url of page. if logout exist inside of return url remove it
i hope it can help you
I have a bookmarklet that injects a button on a foreign webpage. When the button is clicked, a popup containing a page from my website appears.
I am using a PHP framework called Laravel, tested using Chrome browser
Problem: When I check whether the user is logged in from the page originating from my website which is within the popup window, it always returns that the user is not logged in.
if( Auth::guest() ) {
echo "Not logged in";
} else {
echo "Logged in";
}
However, when I visit the same page directly (not within a popup window opened from another website), I can see that I am logged in!
What is the issue here, and how can this be fixed?
Popup JS Code
var popupOptions = 'status=no,resizable=yes,scrollbars=yes,personalbar=no,directories=no,location=no,toolbar=no,menubar=no,width=632,height=295,left=0,top=0';
window.open(' http://www.domain.com/controllername/add?url='+url, '_blank', popupOptions);
You shouldn't be having two cookies with the same name. It looks like the popup window is setting another cookie with same name but different domain overwriting the valid one which should be for domain.com
I'm working on a jquery mobile web app and do a sessioncheck with php on pages I need the user to be logged-in. If not, the user will be redirected to the login.php?r=L29yZGVyLnBocD9kZWFsX2lkPTEwMDM2MjM= (base64_encode($_SERVER['REQUEST_URI']) to login. After the login he has to be redirected to the page he actually requested.
Unfortunately JQM doesn't update the URL, so i can't grab the GET parameter ?r=.... as it is not there. Just a page reload (F5) updates the url.
Here the sessioncheck code which does the redirect if user is not logged-in:
if(!isset($_SESSION["member"]) || (isset($_SESSION["member"]) && (int)$_SESSION["member"]["member_id"]==0)){
unset($_SESSION["member"]);
Header("Location: " . SITE_ROOT . "/login.php?r=".base64_encode($_SERVER['REQUEST_URI']));
exit;
}
What do you guys suggest to tell jQuery mobile that the target has changed.
Of course my redirect happens before the DOCTYPE tag
Cheers
Did you specify a data-url attribute into the page div?
<div data-role="page" data-url="/login" id="login-page">