Welcome Guest, Not a member yet? Register   Sign In
Session/Login Question
#1

[eluser]macleodjb[/eluser]
I'm new to CI so i'm not quite sure what the limitations are at the moment so i have a few questions that were not discussed in the user docs.

1. assume i have sessions being stored in table data enabled in my config file, i am adding some custom variables to the session data array such as 'user_id' and 'user_name'. Can you also include those variables in your database table?

2. I have a bidding section on my site, how can i redirect a user to the login page if they click the "submit bid" button and are not logged in?

3. Normally with php i would check if my session data exists like this $_SESSION['user_id']. If i want to restrict certain pages from users that are NOT logged in, Where would i place an eject script, in my controller, or view? ie..(if(is_logged_in()){go) else (redirect))

4. What's the difference between flashdata and the validation error message?

5. With codeigniters session library, is it possible to return the amount of users currently logged in? if so, how?

Thanks.
#2

[eluser]Colin Williams[/eluser]
1.) I usually use a generic "Variable" model that mimics config.

2.) redirect('user/login');

3.) if ( ! $this->session->userdata(USER_IS_AUTHENTICATED)) { redirect('user/login'); }

4.) Flashdata is a type of session variable that only lasts for one request. Error messages are non-persistent data stored in the validation object

5.) Sessions would not be the way to check that. You would use a database to store such activity (There is usually a session table used by CI, but the Session class has no real interface to it. Query it manually).




Theme © iAndrew 2016 - Forum software by © MyBB