php - Redirect whole website to one url -
i have multiple views in website, code:
$this->load->view('templates/header'); $this->load->view('main'); $this->load->view('templates/footer');
i have div in main load view when click on button. js code:
$("#side").load("/admin/side/loadnewcontact", function(e) { $("#side").removeclass('hide'); });
a separate function checks if user stil valid , logged in everytime request done.
when user not valid system needs go login page. have code it:
redirect('/', 'location');
this works. problem.
when load page inside main js, , user not valid. system redirects / (the login page). view loaded in side, not want. want whole system redirected login instead of specific view.
if understand problem corectly, need if else wraps current jquery code:
//pseudo code var valid_user = <?php echo $valid_user;//this should value or false/null?> if (valid_user) { $("#side").load("/admin/side/loadnewcontact", function(e) { $("#side").removeclass('hide'); }); } else { // similar behavior http redirect //window.location.replace("<?php echo base_url();?>"); // similar behavior clicking on link //window.location.href = "/"; }
you want check javascript variable @ beginning of file/document can make similar conditions due file accordingly. saying in case of buttons/classes need shown regarding valid_user
state.
Comments
Post a Comment