Welcome Guest, Not a member yet? Register   Sign In
strange session class problem
#1

[eluser]gfields[/eluser]
Hi,
i've a strange problem related to the session class in codeigniter.
in a simple controller i check the session for a variable called "sess-language". If it doesn't exist i set the variable.
i've created a view to test the code. it works. but if i add html code to the view the session stops working, and everytime I load another page the session seems to be reinitialized. But the session_id doesn't change at all.
Any idea?

Thanx

Kingcole
#2

[eluser]InsiteFX[/eluser]
It would help to see your Controller and View code!

Enjoy
InsiteFX
#3

[eluser]gfields[/eluser]
Ok, I attach my simple application directory to the post.
The controller HOME loads views "home" and "footer".
if I add more html code in the "home" view, the session language variable (you can check it on the top of the page) stops working
#4

[eluser]InsiteFX[/eluser]
Hi,

I have look at the code you sent, and so far this is what I found:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;

&lt;head&gt;
&lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
&lt;title&gt;Untitled 1&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

    &lt;!-- home - This is what you have, your missing all the above header stuff. --&gt;
    
    <div>
    
        <ul>
    
            <li><a href="http://localhost/">home</a></li>
            <li><a href="http://localhost/index.php/home/cambialingua/it">ITA</a></li>
            <li><a href="http://localhost/index.php/home/cambialingua/en">EN</a></li>
            <li><a ></a></li>
            <hr/>
    
            <li>language: &lt;?=$language?&gt;</li>
            <li>language_desc: &lt;?=$language_desc?&gt;</li>
            <li>lang_codifica: &lt;?=$lang_codifica?&gt;</li>
            <hr/>
        
            <li>title: &lt;?=$this->lang->line('main_title')?&gt;</li>
            <li>altro test: &lt;?=$this->lang->line('lang-test')?&gt;</li>
            <hr />

            <li>sessio ID: &lt;?=$session_id?&gt;</li>    
            <hr/>

            <li>Main MENU:</li>
            &lt;?php foreach($main_menu as $item): ?&gt;
                <li><a href="#">&lt;?=$item->testo ?&gt;</a> |</li>
            &lt;?php endforeach ?&gt;
    
        </ul>

    </div>
    
    &lt;!-- footer section --&gt;
    
    <div>
    
        <div id="footer">
            footer info
        </div>
        
    </div>

&lt;/body&gt;

&lt;/html&gt;

The forums took one of your <li> lines out.

Let me know if that fixes the problem

Also I would use the database sessions.

Enjoy
InsiteFX
#5

[eluser]gfields[/eluser]
Hi,
thank you for the help. I know that in my view code misses all the html stuff. Was only for testing purpose. If I add all the html code to my page the session stops working. But it happens only with that code. If I write anything else the session works. Misteriously.
I debugged with netbeans-xdebug and noting strange seems to happen.

The question is, can a bad html code reset the session?

ciao
Gfields
#6

[eluser]InsiteFX[/eluser]
Try adding a ob_start(); just below the top &lt;?php tag in your Controller

IF sessions quit working do you get any error messages?

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB