Welcome Guest, Not a member yet? Register   Sign In
Page is not loading for users registered
#1

(This post was last modified: 08-10-2020, 04:39 PM by FJ22.)

Hi, I am using codeigniter to create an online platform for a school. Admin logs in but when I try to create new users, they cannot log in. The link that is loaded is correct but the dashboard is not showing. The session works but still is not showing the dashboard. I wrote the same code as I wrote for admin but only admin can log in. What might be the reason for that?

Many thanks.

codeigniter version 3.1.11
php version 7.2.30
Reply
#2

No way of knowing without seeing the code you use for them to login.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 08-11-2020, 07:46 AM by jreklund.)

(08-11-2020, 03:47 AM)InsiteFX Wrote: No way of knowing without seeing the code you use for them to login.

I think the problem is in session. In config.php I have this code:

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE

I have created a table in my database called ci_sessions with columns: id (type int autoincrement), ip_address (type longtext), timestamp (type int), data (type blob). When I log in as admin, nothing is saved in ci_sessions table. Do you think that is causing the error? I have made the connection with the database in the database.php
Reply
#4

(This post was last modified: 08-12-2020, 04:29 AM by InsiteFX.)

These are the session tables:

Code:
For MySQL:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(128) NOT NULL,
        `ip_address` varchar(45) NOT NULL,
        `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
        `data` blob NOT NULL,
        KEY `ci_sessions_timestamp` (`timestamp`)
);

-------------------------------------------------------------

For PostgreSQL:

CREATE TABLE "ci_sessions" (
        "id" varchar(128) NOT NULL,
        "ip_address" varchar(45) NOT NULL,
        "timestamp" bigint DEFAULT 0 NOT NULL,
        "data" text DEFAULT '' NOT NULL
);

CREATE INDEX "ci_sessions_timestamp" ON "ci_sessions" ("timestamp");

Can you show the code that is updating the session when they register and login?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 08-12-2020, 08:35 AM by FJ22.)

(08-12-2020, 04:27 AM)InsiteFX Wrote: These are the session tables:

Code:
For MySQL:

CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(128) NOT NULL,
        `ip_address` varchar(45) NOT NULL,
        `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
        `data` blob NOT NULL,
        KEY `ci_sessions_timestamp` (`timestamp`)
);

-------------------------------------------------------------

For PostgreSQL:

CREATE TABLE "ci_sessions" (
        "id" varchar(128) NOT NULL,
        "ip_address" varchar(45) NOT NULL,
        "timestamp" bigint DEFAULT 0 NOT NULL,
        "data" text DEFAULT '' NOT NULL
);

CREATE INDEX "ci_sessions_timestamp" ON "ci_sessions" ("timestamp");

Can you show the code that is updating the session when they register and login?

Many thanks for your reply. I have copied the MySQL code that you sent me and I have the new ci_sessions table in my database. I have sent you the file that updates the ci_sessions (Session_database_driver.php). I have also sent you 4 files. The Login.php which is the file in controllers folder. In this file I check if admin or parent (other user) has logged in or logged out. The second file I have sent you is Login_model.php which is a file saved in models folder. Admin.php and Parents.php (both are in controllers folder). Admin can log in and I can see the dashboard. When I try to log in as parent user, it logs in and links to the dasboard but I cannot see the dashboard. For both admin and parent users, in ci_sessions nothing is saved when they log in.

Attached Files
.php   Admin.php (Size: 2.86 KB / Downloads: 5)
.php   Login.php (Size: 2.24 KB / Downloads: 5)
.php   Login_model.php (Size: 2.45 KB / Downloads: 4)
.php   Parents.php (Size: 2.55 KB / Downloads: 3)
.php   Session_database_driver.php (Size: 10.9 KB / Downloads: 3)
Reply
#6

You should have a separate model for admin and parents.

Your trying to do two things in the same method login admin and login parents.

Also I would autoload the session library.

PHP Code:
// all of the code like this should not have these ()
return  $this->db->set('login_status', ('1'))

// should be like this.
return  $this->db->set('login_status''1'

You do not need the () around '1' take out all of the extra ().
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(08-13-2020, 05:05 AM)InsiteFX Wrote: You should have a separate model for admin and parents.

Your trying to do two things in the same method login admin and login parents.

Also I would autoload the session library.

PHP Code:
// all of the code like this should not have these ()
return  $this->db->set('login_status', ('1'))
// should be like this.
return  $this->db->set('login_status''1'

You do not need the () around '1' take out all of the extra ().
Thanks for your advises. I created Login_admin_model.php and Login_parents_model.php and I used the same Login controller and I also added session in autoload like: 
$autoload['libraries'] = array('pagination', 'xmlrpc' , 'form_validation', 'email','upload','paypal', 'session');
I removed also the () outside '1' .
However, I still can't see the parent dashboard.
Reply
#8

You should remove the () all statements that have them.

Why are you sending both the admin and parents to the same dashboard?

By all rights it should work if it's working for admin.

Seems like there is something else wrong in a file I do not have from you.

If you can download and install Skype and TeamViewer I can help you from here.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(This post was last modified: 08-13-2020, 11:15 AM by FJ22.)

(08-13-2020, 10:26 AM)InsiteFX Wrote: You should remove the () all statements that have them.

Why are you sending both the admin and parents to the same dashboard?

By all rights it should work if it's working for admin.

Seems like there is something else wrong in a file I do not have from you.

If you can download and install Skype and TeamViewer I can help you from here.

Yes I did remove all the () and I think it should have been working by now but I don't know what is causing the error. In my view folder I have an admin folder that has dashboard.php and in parents view folder I have another dashboard.php From the Login controller I go to the admin view folder and get the dashboard of admin by writing: if($this->session->userdata('admin_login') == 1) redirect(base_url(). 'admin/dashboard', 'refresh');
and I go to parents view folder and get the dashboard of parents by writing: if ($this->session->userdata('parents_login') == 1) redirect(base_url(). 'parents/dashboard', 'refresh');
However, I did try to rename the dashboard files so they were different but still the issue is the same. I do have TeamViewer and I can send you the id and password by email. My email is: [email protected]

(08-13-2020, 10:55 AM)FJ22 Wrote:
(08-13-2020, 10:26 AM)InsiteFX Wrote: You should remove the () all statements that have them.

Why are you sending both the admin and parents to the same dashboard?

By all rights it should work if it's working for admin.

Seems like there is something else wrong in a file I do not have from you.

If you can download and install Skype and TeamViewer I can help you from here.

Yes I did remove all the () and I think it should have been working by now but I don't know what is causing the error. In my view folder I have an admin folder that has dashboard.php and in parents view folder I have another dashboard.php From the Login controller I go to the admin view folder and get the dashboard of admin by writing: if($this->session->userdata('admin_login') == 1) redirect(base_url(). 'admin/dashboard', 'refresh');
and I go to parents view folder and get the dashboard of parents by writing: if ($this->session->userdata('parents_login') == 1) redirect(base_url(). 'parents/dashboard', 'refresh');
However, I did try to rename the dashboard files so they were different but still the issue is the same. I do have TeamViewer and I can send you the id and password by email. My email is: [email protected]

I can otherwise send you my files and database to have a look where might be the error if that is a more convenient way. Many thanks.
Reply
#10

Hi again, are you free tomorrow for a skype/teamviewer session, to have a look at my code? Many thanks.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB