Welcome Guest, Not a member yet? Register   Sign In
Problems with bad SESSION mojo
#1

[eluser]steveHS[/eluser]
My site at http://rcta.rp-network.com/ is large with over 60-views. Each view has it's own controller with the same name as the view. Each controller calls a large helper file (approx 6000 lines of code with 100 functions). All works very well except for session variables. The only one I'm interested in persisting is session_id. I've tried both DB and not the DB methods and I can see that each page navigation is indeed a new session. My development utilizes CODA but testing on both FireFox and CODA yields the same result.

The problem is every time the user switches pages, a new session-id is generated and the original one is lost. Here are the config.php parameters:

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

$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";

Is there some magic bullet that I'm missing here as this is my first, and maybe only, CodeIgniter project.

I'm desperate, please help and thanks.
#2

[eluser]bobbob[/eluser]
Quote:The problem is every time the user switches pages, a new session-id is generated and the original one is lost.
the user should still be correctly associated with the new id.
Are you setting any session variables as they should be available regardless of the regeneration?
#3

[eluser]steveHS[/eluser]
Exactly my problem only stated better. I did try to set session variables at one time but they were not persisted. So, if I can persist any unique fact about the user I can store/lookup details in the database.

Thanks,

S
#4

[eluser]jedd[/eluser]
So on your browser tests, are you seeing a cookie being generated?

I just hit that page, and I didn't get asked about cookies (my browser is configured to ask me on every attempt to give me a cookie). This isn't, of course, a good sign .. given your question. Wink

As an aside, page-source on your page suggests some problems. First and most obvious is that the first character is not a < .. which might cause you grief. It looks like it's causing some recognised grief within your code, too. Hmm, the forum code is trimming the leading spaces before your initial &lt;!-- comment field there. You probably want to check your page source yourself.

Code:
&lt;!-- <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /nfs/c03/h04/mnt/49671/domains/rcta.rp-network.com/html/system/application/config/autoload.php:1)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 668</p>

</div> --&gt;&lt;!-- <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  sessid</p>
<p>Filename: helpers/rcta_helper.php</p>
<p>Line Number: 98</p>

</div> --&gt;00_00<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;!-- homepage_00_00b   --&gt;   &lt;!-- <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at /nfs/c03/h04/mnt/49671/domains/rcta.rp-network.com/html/system/application/config/autoload.php:1)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 668</p>

</div> --&gt;&lt;!-- <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  sessid</p>
<p>Filename: helpers/rcta_helper.php</p>
<p>Line Number: 98</p>

</div> --&gt;00_00<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;!-- homepage_00_00b   --&gt;
#5

[eluser]steveHS[/eluser]
Yes, that chunk of code comes from the stock Session.php as follows:

//echo $this->sess_expiration + time() + (7 * 24 * 60 * 60);
setcookie(
$this->sess_cookie_name,
$cookie_data,
$this->sess_expiration + time() + (7 * 24 * 60 * 60),
$this->cookie_path,
$this->cookie_domain,
0
);
Here it is trying to create another cookie. But that is the problem, I don't want it to do this. It complains because there is already one present, I think.




Theme © iAndrew 2016 - Forum software by © MyBB