Redirect from Libraries |
<?php
if (!defined('BASEPATH')) die('No direct script access allowed'); class UserInfo { var $CI; var $userId; var $userDisplayName; var $userEmail; var $userThumb; public function __construct($params = array()) { $this->CI =& get_instance(); $this->CI->load->helper('url'); $this->CI->config->item('base_url'); $this->CI->load->database(); //Optional if any database interaction needed $this->getUser(); } public function getUser(){ if(empty($this->CI->session->userdata('sessionUid'))){ redirect(base_url()); }else{ $this->userId = $this->CI->session->userdata('sessionUid'); $this->userEmail = $this->CI->session->userdata('sessionMail'); $this->userDisplayName = $this->CI->session->userdata('sessionDname'); $this->userThumb = $this->CI->session->userdata('sessionThumb'); } } } ?> Above is my Code where i have created a new Library Class "UserInfo" and auto loading this library in autoload.php $autoload['libraries'] = array('ActiveRecord','database','session','UserInfo'); However when a session is not exist(here i am checking the session "sessionUid") it should take me to the baseurl but it is throwing 500 error. if i am commenting that redirect script the page is loading fine. Any help will be highly appreciated. Thanks Smrutikant
@[email protected]
How is your base_url configured? Also, have you tried a different page to see it that works?
(11-09-2018, 05:57 AM)[email protected] Wrote: <?php Using base_url() as an argument redirect() is not necessasary e.g. redirect(base_url()); redirect() figures out what base_url is by itself and will incorporate it into the new location URL
Try that:
PHP Code: redirect('/'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Check and see if your web page is being cached.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |