Welcome Guest, Not a member yet? Register   Sign In
Where to declare global variables?
#13

[eluser]daelsepara[/eluser]
take note too that when using cookies (whether native PHP cookies or via CodeIgniter's Helper function), you must refresh the page or redirect it to a new one for the
cookie values to be active, either way, it can easily be implemented in the controller.

e.g.

Code:
//controller: sample
function index()
{
    $this->load>helper('cookie'); //can also be placed in the constructor
    set_cookie('test_cookie','test',0);
    redirect('sample/main');
}

function main()
{
    $this->load>helper('cookie'); //can also be placed in the constructor
    $cookie = get_cookie('test_cookie');

    //render page, i.e. load views, etc.
}


Messages In This Thread
Where to declare global variables? - by El Forum - 05-14-2010, 01:52 PM
Where to declare global variables? - by El Forum - 05-14-2010, 02:23 PM
Where to declare global variables? - by El Forum - 05-14-2010, 02:25 PM
Where to declare global variables? - by El Forum - 05-14-2010, 02:27 PM
Where to declare global variables? - by El Forum - 05-14-2010, 02:34 PM
Where to declare global variables? - by El Forum - 05-14-2010, 02:45 PM
Where to declare global variables? - by El Forum - 05-14-2010, 03:23 PM
Where to declare global variables? - by El Forum - 05-14-2010, 07:52 PM
Where to declare global variables? - by El Forum - 11-16-2010, 10:16 AM
Where to declare global variables? - by El Forum - 11-17-2010, 04:38 AM
Where to declare global variables? - by El Forum - 11-17-2010, 03:23 PM
Where to declare global variables? - by El Forum - 01-16-2011, 11:39 AM
Where to declare global variables? - by El Forum - 01-18-2011, 09:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB