Welcome Guest, Not a member yet? Register   Sign In
How to know if a model is already loaded?
#1

[eluser]Unknown[/eluser]
Hi everyone!

I'm so sorry but I don't found anywhere what I'm looking for to solve my problem (..and sorry for my English.. I'm italian ) Tongue

...that's my problem:
in the constructor of the controller I load a model that I use in the head of the index function:
Code:
function index() {
if ( $this->login_model->_is_logged() ) {
  //show logged in page
}
else {
  //show login form
}
}
and it works perfectly... if I don't reload the page shown Big Grin

The "_is_logged()" function checks session and cookies, but these contain a encrypted part of the data passed via form.

When I refresh the "logged in" page, without resending data, it goes back, obviously, at the login form, because it reloads the model again and the saved datas are lost.


How can I know if a model is already loaded or not?


Thanks guys Smile


edit: oh.. I've seen this is not the correct section for my question Sad ..excuse me..
#2

[eluser]Unknown[/eluser]
Up?
#3

[eluser]InsiteFX[/eluser]
Your login information should be stored in sessions.

Read the CodeIgniter User Guide session library.

InsiteFX
#4

[eluser]abedzilla[/eluser]
You can use the log_message() function and put it in the constructor, so it will be executed when it initiated

Put this in your model's constructor (parent::Model())

Code:
log_message ("debug", "Yourmodel is loaded");

don't forget to set the log config to debug mode, see the config.php file

Code:
$config['log_threshold'] = 2;

And set the system/logs directory permission to writable (by default CI will create the log files here)

or set the logs directory in another dir
Code:
$config['log_path'] = 'another/directory/logs/';

CI will then create the log file in the directory. monitor the log files as you like. You can get the debug message to see if your model is already loaded or not in the log files.




Theme © iAndrew 2016 - Forum software by © MyBB