Welcome Guest, Not a member yet? Register   Sign In
Why can't I do this in CI?
#1

[eluser]Yunohoo[/eluser]
I thought it was an issue with my logic, but after more expirementing I'm starting to think the reason my script isn't working has to do with CI.

I'm making an admin panel for my site. It uses it's own custom session class as well. So far I just have the session library and the controller. The controller handles the login, the session class handles the validation of that session. While it's valid, it'll keep the users data meaning s/he is logged in. Once all that becomes unset, the session is considered void.

The admin session class has a variable called $_session_id, which is meant to be set from the admin controller, this is what is not happening for some reason.

Here is my admin controller:
http://pastebin.com/MkGf2hNP

Function set_session is what is not properly setting the session id.

Here is the session class:
http://pastebin.com/hiDhmv4D

I've created my own code not using CI following the same logic which works perfectly.
This is what I came up with:
Code:
<?php
class sessions
{
    protected $session_id;
    
    public function __construct()
    {
        echo $this->session_id;
    }
    public function set_session($sid)
    {
        $this->session_id = $sid;
    }
}

class admin
{
    public function index()
    {
        $this->sessions = new sessions;
        $this->login();
        
        // before - sessions Object ( [session_id:protected] =>  )
        print_r($this->sessions);
        // after  - sessions Object ( [session_id:protected] => 123456 )
    }
    public function login()
    {
        if(isset($_POST['process']))
        {
            $this->sessions->set_session('123456');
        }
        echo <<&lt;HTML
        &lt;form method="post">
        &lt;input type="text" /&gt;
        &lt;input type="submit" name="process" /&gt;
        &lt;/form&gt;
HTML;
    }
}

$admin = new admin;
$admin->index();

So this follows the same logic I'm using in my CI script which works, while the code in CI doesn't.

Any reason why? Am I not understanding something somewhere?

Any help will be greatly appreciated, thanks.


Messages In This Thread
Why can't I do this in CI? - by El Forum - 07-11-2012, 02:25 PM
Why can't I do this in CI? - by El Forum - 07-11-2012, 10:16 PM
Why can't I do this in CI? - by El Forum - 07-11-2012, 11:37 PM
Why can't I do this in CI? - by El Forum - 07-11-2012, 11:42 PM
Why can't I do this in CI? - by El Forum - 07-11-2012, 11:55 PM
Why can't I do this in CI? - by El Forum - 07-11-2012, 11:57 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 12:44 AM
Why can't I do this in CI? - by El Forum - 07-12-2012, 05:44 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 06:41 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 07:13 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 07:33 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 08:41 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 08:44 PM
Why can't I do this in CI? - by El Forum - 07-12-2012, 09:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB