Codeigniter ci_sessions table storing ip address as 0.0.0.0 why? even when hosted I am getting 0.0.0.0

前提是你 提交于 2019-12-08 05:04:40

问题


Hello in my codeigniter I have created table as ci_sessions with following fields

CREATE TABLE IF NOT EXISTS  `ci_sessions` (
    session_id varchar(40) DEFAULT '0' NOT NULL,
    ip_address varchar(45) DEFAULT '0' NOT NULL,
    user_agent varchar(120) NOT NULL,
    last_activity int(10) unsigned DEFAULT 0 NOT NULL,
    user_data text NOT NULL,
    PRIMARY KEY (session_id),
    KEY `last_activity_idx` (`last_activity`)
);

Every field is working fine, except ip address which is storing as 0.0.0.0 for every client. I have edited my config.php as below.

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

回答1:


With Linode your app is likely behind a proxy. You can either find out your proxy IP and add it to the whitelist in your CodeIgniter config file (bottom of /application/config/config.php), or follow the directions on Linode's Nodebalancer Reference for using the Apache mod_rpaf module to remap X_FORWARDED_FOR to REMOTE_ADDR.



来源:https://stackoverflow.com/questions/29367137/codeigniter-ci-sessions-table-storing-ip-address-as-0-0-0-0-why-even-when-hoste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!