Welcome Guest, Not a member yet? Register   Sign In
Logged in members..
#1

[eluser]Roy MJ[/eluser]
Hi,

I was wondering if anyone has an idea of getting the active members who are logged-in a website.. Is it possible to get the value from sessions..?? My thght till now is that while user logs in we shud create a status field in the table and when he is logged in then the field shud be 2 and if its logged out it shud be 0. In this forum itself it has got a place at the bottom in forum home where it shows all active members..
#2

[eluser]InsiteFX[/eluser]
Here is the table structures.
Code:
--
--  Table structure for users table.
--
DROP TABLE IF EXISTS users;

CREATE TABLE `users` (
  `users_id`       int(11)      unsigned NOT NULL AUTO_INCREMENT,
  `users_name`     varchar(40)           NOT NULL,
  `users_email`    varchar(255)          NOT NULL,
  `users_password` varchar(32)           NOT NULL,
  `user_level`     tinyint(1)            NOT NULL,
  `timestamp`      int(11)      unsigned NOT NULL,
  PRIMARY KEY (`users_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
--  Table structure for users_online table.
--
DROP TABLE IF EXISTS users_online;

CREATE TABLE `users_online` (
  `users_id`    int(11)     unsigned NOT NULL,
  `user_name`    varchar(40)          NOT NULL,
  `timestamp`    int(11)     unsigned NOT NULL,
  PRIMARY KEY (`users_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
--  Table structure for guests_online table.
--
DROP TABLE IF EXISTS visitors_online;

CREATE TABLE `visitors_online` (
  `ip_address` varchar(16)          NOT NULL DEFAULT '0',
  `timestamp`  int(11)     unsigned NOT NULL,
  PRIMARY KEY (`ip_address`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
--  Table structure for users_banned table.
--
DROP TABLE IF EXISTS users_banned;

CREATE TABLE `users_banned` (
  `users_id`    int(11)     unsigned             NOT NULL,
  `ip_address`    varchar(16)          DEFAULT '0' NOT NULL,
  `user_name`    varchar(40)                      NOT NULL,
  `timestamp`    int(11)     unsigned             NOT NULL,
  PRIMARY KEY (`users_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

InsiteFX
#3

[eluser]Roy MJ[/eluser]
wow.. this is cool.. I was thinkin nonsense until i read the above.. Adding members to online members table is fine.. But will it be deleted if the user logs out(consider i include the deletion part in the logout controller )? cuz i have had experiences of logout not working properly, if i click back in the browser the session will also trace back..Sad. Also how will i get the visitors ip address when they reach any of my website pages.. Or this is done only for homepage... Will this do?? I just searched it from the user guide..
Code:
$this->input->ip_address();
And im doing this without any form or any kind of submitting thing in the view side except tht someone will be logged in from a particular IP..
#4

[eluser]Joseph Wensley[/eluser]
Just search for users where the timestamp is less than say 10 min old. Just make sure you update the timestamp every time they load a page.
#5

[eluser]Roy MJ[/eluser]
ok.. so i just have to update the table virtually on every function using time();..?? or can it be done in site_settings...??
#6

[eluser]InsiteFX[/eluser]
In your auth library constructor check to see if they are login if not then log them in as a visitor like a dummy login, then add the vistor to the visitors_online table.

If they are a user then log them in and add them to the users_online table.

You will also need to check for banned users on your login.

When a visitor logs out and leaves you need to delete them from the visitors_online table also when a user logs out you need to delete them form the users_online table.

I am writing a new auth system that will be using all of this now...

InsiteFX
#7

[eluser]Roy MJ[/eluser]
Oh k very nice then.. so will wait for your updates regarding this..




Theme © iAndrew 2016 - Forum software by © MyBB