I want to create a login system in Codeigniter 4 like this so when the user has logged in on 1 browser / other device, and tries to log back in on another browser / other device then for the first login he will be logged out automatically

examples like this I log in to the Mozilla browser and I try to log in again in the Chrome browser, then when I log in again in the Chrome browser my login in the Mozilla browser will log out

Recommended Answers

All 5 Replies

I don’t have experience with CI4 but I wrote DaniWeb on CI3. What do you mean about double login? Maybe I can do some research and help.

commented: I've edited my question +0

I think you need a better example. I'm currently logged in on my phone, laptop and another tablet with Chrome. I can only guess there is some Google setting I haven't explored yet.

commented: i mean like i just can one time login +0
commented: i mean like this now i login in mozila browser then i open another browser like chrome if i login in chrome yang login in mozila will auto logout +0

OK, I see the updated question now.

You should be able to do this by, each time that a user logs in, store a cookie in their web browser with a random token / string. Then, store a flag in the database for the user of that same token / string. Each time that they load a page on your site, compare the value in user's cookie to see if it matches the value associated with the user in the database. If they don't match, log the user out. If they do match, then you know the latest login was performed from that browser.

I've scoured https://myaccount.google.com/ and more and it doesn't appear to be a Chrome or Google account feature. That said, Dani is spot on.

: i mean like this now i login in mozila browser then i open another browser like chrome if i login in chrome yang login in mozila will auto logout

I'm currently logged in on Firefox and Chrome so the stock setup doesn't autologout.

Remember that we can configure PCs and apps almost anyway we want. Here I can't guess how you made these browsers do that. You would have to tell me how you did that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.