Welcome Guest, Not a member yet? Register   Sign In
Session creates new session id on every page load
#31

[eluser]WanWizard[/eluser]
The cookie domain must be the hostname, or the domain part of the hostname. It may not contain 'http://'.

The underscore is in 'sess_cookie_name' (by default it is set to "ci_session", which is a very bad default).
#32

[eluser]Lockzi[/eluser]
[quote author="WanWizard" date="1287063646"]The cookie domain must be the hostname, or the domain part of the hostname. It may not contain 'http://'.

The underscore is in 'sess_cookie_name' (by default it is set to "ci_session", which is a very bad default).[/quote]

Thank you!

It was the "http://" in the cookie domain that caused the problems for me!

I solved the problem by using:

Code:
$config['cookie_domain']    = str_replace("http://", "", str_replace("https://", "", $config['base_url']));

Really grateful,
Lockzi
#33

[eluser]WanWizard[/eluser]
I use this:
Code:
// determine the domain and the path from the base_url
$base_url_parts = parse_url($config['base_url']);
$config['cookie_domain']    = $base_url_parts['host'];
$config['cookie_path']        = $base_url_parts['path'];
unset($base_url_parts);
This also sets the path right if you haven't installed the application in the website docroot, but in a directory...
#34

[eluser]Lockzi[/eluser]
[quote author="WanWizard" date="1287080532"]I use this:
Code:
// determine the domain and the path from the base_url
$base_url_parts = parse_url($config['base_url']);
$config['cookie_domain']    = $base_url_parts['host'];
$config['cookie_path']        = $base_url_parts['path'];
unset($base_url_parts);
This also sets the path right if you haven't installed the application in the website docroot, but in a directory...[/quote]

Yours didn't work for me at all...

Code:
Notice: Undefined index: path in /home/auinterface/public_html/application/config/config.php on line 257
A PHP Error was encountered

Severity: Notice

Message: Undefined index: path

Filename: config/config.php

Line Number: 257

The reason is that my $base_url_parts only exists of:
Code:
Array ( [scheme] => http [host] => subdomain.domain.se ) 1

You need to set path to '/' as default in case of the application actually is in the web root.

This would be a solution:

Code:
// determine the domain and the path from the base_url
$base_url_parts = parse_url($config['base_url']);
if(!key_exists('path', $base_url_parts))
{
    $base_url_parts['path'] = '/';
}
die(print_r($base_url_parts));
$config['cookie_domain']    = $base_url_parts['host'];
$config['cookie_path']        = $base_url_parts['path'];
unset($base_url_parts);

But I really rather go with mine in that case... Tongue


EDIT:
I just realized a huge problem... I'm not ending the $config['base_url'] with /.

Thanks for allowing me to find that problem Big Grin
#35

[eluser]WanWizard[/eluser]
Glad to be of service... :coolsmile:
#36

[eluser]Unknown[/eluser]
I have this problem, I try everything but cant solve...
Any one help me plz...
#37

[eluser]stirado[/eluser]
Same here. I tried everything suggested on this thread but the problem remains.

I'm running Codeigniter Reactor 2.0.2 (also tried with latest Core version) on a Wampserver 2.1a on top of Windows Vista and my application works flawlessly. When I move it to a LAMP Ubuntu Server 11.04 and watch the member_session table (see configuration below) I see that each time I load a page two new rows appear with a different session_id

Code:
$config['base_url']    = 'http://intranet.example.com';

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

$config['cookie_prefix'] = "";
$config['cookie_domain'] = ".example.com";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;

As I said, I already tried everything suggested on this thread and other threads as well.

One of the comments suggests that the problem could be with the Apache configuration. I'm using the default, I just added the ServerName directive

Code:
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.com

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

</VirtualHost>

Someone suggested this problem should be solved in two minutes. I've been stuck for several days. I'm willing to pay to have this solved. Someone willing to help?
#38

[eluser]stirado[/eluser]
FWIW.

In my case the problem was that the user_agent field on the ci_sessions database table didn't have enough space, so the query wasn't finding the cookie and went ahead to insert a new one.
#39

[eluser]Unknown[/eluser]
A recent change in CI-Reactor was made to the session table (user_agent was changed from a length of 50, to 120). The CI User Guide that is available from the website has yet to be updated with the latest version. The proper sql for the session table is as follows:

Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
    session_id varchar(40) DEFAULT '0' NOT NULL,
    ip_address varchar(16) 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`)
);

This change can be found at the Bitbucket repo here.
#40

[eluser]Unknown[/eluser]
I have already been running my dev environment as a vhost with a fake domain, and I followed the rest of the advice in this thread as closely as possible. However I am still getting a brand new session on each page load. I can’t even get it to work with an actual domain in a staging environment.
http://www.thomassabojewelleryaustralia.com/




Theme © iAndrew 2016 - Forum software by © MyBB