Welcome Guest, Not a member yet? Register   Sign In
Global functions
#1

[eluser]RyanStubbs[/eluser]
Hey.

I'm trying to code a user management script and I was wondering which was the best way to create a function that can be run from any controller and can return a value of either 0 or 1.

I'm talking about a user_is_logged() function that checks the session data to see if the user is logged in and then can be used within controllers to choose the appropriate action to apply to the user (such as redirecting to homepage or login form).

I'm pretty new to CodeIgniter so I wouldn't know how to translate this to CI without your assistance.

Thanks a lot.

Ryan.
#2

[eluser]alboyd[/eluser]
Put it in a library or create a basecontroller that you can use to extend your controllers. I think library is most appropriate for what you are talking about though.

Check out the info at http://ellislab.com/codeigniter/user-gui...aries.html
#3

[eluser]InsiteFX[/eluser]
If it's just a function / method place it into a helper, then add it to your autoload config.

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB