Welcome Guest, Not a member yet? Register   Sign In
Problem with $_COOKIE

Hi, i'm a newbie in PHP and codeigniter.

i have a problem regarding cookie.

here's the code

class controller_a extends CI_Controller {
function setcookies()
setcookie('uname', 'mycookie', time()+3600);


class controller_b extends CI_Controller {
function viewcookies()
$data['uname'] = $_COOKIE['uname'];
$this->load->view('view_cookie', $data);

//notes constructor omitted to view only the code that have a problem

when i'm trying the retrieve the cookie the error occurs, BUT when i put the
viewcookies() function to controller_a, it retrieve the cookie named uname with no error and the view display the msg 'mycookie'

so my conclusion is, the cookie it only known where it was declared. in the example it was
known only in controller_a not known in controller_b.

so how to declare a cookie that all the controllers can retrieve it?

hope you can help me guys.

many thanks.

Theme © iAndrew 2016 - Forum software by © MyBB