Welcome Guest, Not a member yet? Register   Sign In
ci_session with multiple database not working
#1

I am working on a project where using two databases. My requirement is that, Depending on user login type load database e.g.

For user type 1 load db1(default database) Or For user type 2 load db2. Problem is that if login with user type 1 then logged in successfully but if login with user type 2 then login failed due to the ci_session table. how to fix this issue.
Reply
#2

@samtron,

Why don't you initiate the session after the user is verified? If the login fails then simply send an error message and don't start the session.
Reply
#3

(05-02-2019, 06:53 PM)php_rocs Wrote: @samtron,

Why don't you initiate the session after the user is verified?  If the login fails then simply send an error message and don't start the session.

You means don't use autoload session?
Reply
#4

@samtron,

Correct. You can wait to initialize a session after the user has successfully logged into the application.
Reply
#5

(This post was last modified: 05-03-2019, 07:40 AM by dave friend.)

(05-02-2019, 06:53 PM)php_rocs Wrote: Why don't you initiate the session after the user is verified?  If the login fails then simply send an error message and don't start the session.

Because the session is used to identify someone who has successfully logged in but has been redirected to, or has navigated to some other page.
Reply
#6

(05-03-2019, 05:28 AM)php_rocs Wrote: @samtron,

Correct.  You can wait to initialize a session after the user has successfully logged into the application.

Ok, Thankyou
Reply
#7

(This post was last modified: 05-03-2019, 08:01 AM by dave friend.)

(05-02-2019, 01:17 PM)samtron Wrote: Problem is that if login with user type 1 then logged in successfully but if login with user type 2 then login failed due to the ci_session table. how to fix this issue.

The fix is to not use
PHP Code:
$config['sess_driver'] = 'database'

Any other driver will work.
Reply
#8

(This post was last modified: 05-03-2019, 10:49 AM by ciadmin.)

(05-03-2019, 08:01 AM)dave friend Wrote:
(05-02-2019, 01:17 PM)samtron Wrote: Problem is that if login with user type 1 then logged in successfully but if login with user type 2 then login failed due to the ci_session table. how to fix this issue.

The fix is to not use
PHP Code:
$config['sess_driver'] = 'database'

Any other driver will work.

Any example?
Reply
#9

(05-03-2019, 08:51 AM)samtron Wrote: Any example?

'files', ‘memcached’, or , 'redis'

I usually use 'files'. It's easy to implement and proven to be responsive even on sites with daily session hits in the hundreds of thousands. If you need to handle millions of sessions a day then you want a memcached setup - and a better system admin than me.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB