Community Auth - a database error when logging in |
(05-22-2017, 01:31 PM)skunkbad Wrote:(05-22-2017, 10:08 AM)arie55 Wrote:Instead of(05-22-2017, 07:49 AM)skunkbad Wrote: What is your session config look like? Have you set base_url in config/config? Did you properly set up your encryption key? Here is how I got mine to work. Step 1: Download Codeigniter 3.1.4 from there website. Step 2: Goto phpmyadmin and create a database. Step 3 Open config/config.php and edit the following: * base_url must point to your server since I am using localhost mine will be 'http://localhost/auth/' * index_page remove the 'index.php' so that it just shows '' * enable_hooks should be set to TRUE * encryption_key we will skip this and come back to it later * sess_driver change it to 'database' * sess_save_path remove NULL and enter 'ci_sessions' * global_xss_filtering change that to TRUE Step 4: Now go to phpadmin and click on your database then click on SQL and run the following code: 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`) ); After that completed click on SQL again and run the following: ALTER TABLE ci_sessions ADD PRIMARY KEY (id); Step 5: Now go to config/database.php and enter the details for your database Step 6: Now open config/autoload.php and edit the following: * in libraries add the 'session', 'database', 'email' ---NOW TIME TO INSTALL COMMUNITY AUTH------ Step 1: Download community auth from there site and extract the contents Step 2: open the extracted folder click on skunkbad-community-auth-for-codeigniter-3-28955ea80f13 ->application->third_party and select the communtiy_auth folder and copy that into your_codeigniter_directory->application->third_party Step 3: Go to your_codeigniter_directory->third_party->community_auth. Go ahead and open the community_auth folder. Step 4: Select the following folders and copy them * config * controllers * core * helpers * hooks * libraries * models * views Then go to your_codeigniter_directory->application and right click and select paste. Step 5: go to phpmyadmin and import the sql file located in third_party->community_auth->sql The name of the file will be install.sql Step 6: next go to config/routes.php and add the following at the bottom: $route[LOGIN_PAGE] = 'examples/login' Step 7: Now goto config/hooks.php and add the following: $hook['pre_system'] = array( 'function' => 'auth_constants', 'filename' => 'auth_constants.php', 'filepath' => 'hooks' ); $hook['post_system'] = array( 'function' => 'auth_sess_check', 'filename' => 'auth_sess_check.php', 'filepath' => 'hooks' ); Step 8: Go to your_codeigniter_directory you should see your application folder and system folder. In here you are going to create a .htaccess file and add the following: # MAKE SURE TO LEAVE THE DENY LIST AT THE TOP OF THE FILE !!! # BEGIN DENY LIST -- # END DENY LIST -- RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] This will remove the index.php from the url Step 9: goto http://your_codeigniter_directory/key_creator so that you can generate the key encryption Here I just selected the codeigniter standard 128 bit encryption. This one will be located at the very top of the list. A new page will open giving you the key copy the entire key Now go back to config/config.php and enter that key into the encryption_key filed. I just normall paste it and add // in front of the old one to comment it out. Step 10: Now go to application->controller->Examples.php and edit line 195, 196, and 197 with your details to create the admin account. Make sure that you change auth_level = '9' Step 11: now go to url http://your_codeigniter_directory/examples/create_user you will see a message showing that the user has been created Step 12: now go to http://your_codeigniter_directory/examples/ you should get a message saying that your logged in Step 13: now go to http://your_codeigniter_directory/examples/logout That will log you out. |
Welcome Guest, Not a member yet? Register Sign In |