Welcome Guest, Not a member yet? Register   Sign In
Admin directory


I got a directory there I only got the admin files.
I want to check if the admin is logged in, and got permission to see the pages.

Do i need to check it in every function in the class?

Thanks //Webbhelp

[eluser]Ben Edmunds[/eluser]
You can use a constructor. Constructors are ran when the class is instantiated.

If your on PHP4 then create a method with the same name as the class and then put your code into this method to check the users authentication. If your on PHP5 create a method named __construct and then put your code into this method to check the users authentication.

Yes maybe ,that seems to be a good idé.
But, in codeigniter index, is running first, can i write in in that function to?

And if the visitor don't have permisson the the site, what can I do then, so the other functions can't be runned?


[eluser]Ben Edmunds[/eluser]
Just check for the proper creds in the constructor and if they shouldn't be there redirect them to the page they should be at.

Yes, that is a smart and a simple way, I like it, thanks Smile

Just a question, is it possible in a easy way to give them a message and deny them from the other function?

Thank you so much for helping me Smile

[eluser]Ben Edmunds[/eluser]
What I usually do is set a message in flashdata.

Sorry, but what do you mean?

Thanks Smile

[eluser]Ben Edmunds[/eluser]
Before your redirect:
$this->session->set_flashdata(''message', 'You were redirected because...');

and then at the page you redirected to you can access the message with:

Aha, Now I understans sry Smile

Thank you very much for reply, this is helping me much!

Btw, What do you recommended: use PHP standard sessions or Codeigniters session-class?

Thanks Smile

[eluser]Ben Edmunds[/eluser]
I use both depending on my needs.

The CI session library is good but use whichever suits your needs best.

Theme © iAndrew 2016 - Forum software by © MyBB