CodeIgniter Forums
Controllers - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Controllers (/showthread.php?tid=37121)



Controllers - El Forum - 12-29-2010

[eluser]marcin346[/eluser]
Hello. I'm new 'coder' form Poland.
How can I use function from controller A in controller B ?
For example:
site.php:
...........
...........
...........
function check_login()
{
IF($cookie = $this->input->cookie('cicookie', True))
{
$dane = unserialize(base64_decode($cookie));
IF(is_array($dane))
{
$a = $this->User;
$b = $a->get_user_by_login($dane['user']);
$ar = $b->result_array();
IF(isset($ar[0]) and $ar[0]['user_last_login_ip'] == $this->input->ip_address() and sha1(md5($ar[0]['user_login'].$ar[0]['user_password'])) == $dane['pass'])
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
...................................................
...................................................

add_news.php:

..........................
..........................
function add()
{
check_login();
......................
....................
....................
......................
}
...................................
...............................
...........................


Controllers - El Forum - 12-29-2010

[eluser]gyo[/eluser]
Give a look at this library: Wick

...and welcome! Wink


Controllers - El Forum - 12-29-2010

[eluser]marcin346[/eluser]
Thank you for fast reply also I'm sorry for my bad language.
It's useful library.
Thanks a lot!