0

iam debugging an application which sets cookie via jquery.

$.cookie("cookie_name",'s',{ path: '/'});

how can i fetch the cookie from codeigniter.?

$this->input->cookie('cookie_name', TRUE);

is not returning anything. please help.

Roo
  • 618
  • 1
  • 8
  • 17
  • @dude, it may give some idea http://stackoverflow.com/questions/7086989/jquery-and-php-cookies – RONE Aug 27 '13 at 05:23

5 Answers5

1

Check you have loaded cookie helper like,

$this->load->helper('cookie');

before using it.

If you loaded it then try this print_r($_COOKIE); to check whether your cookie is set or not.

Read http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html

Rohan Kumar
  • 38,998
  • 11
  • 69
  • 99
0

You have to use this jquery plugin there is also brief documentation how to use it. by this you create, delete and edit cookie with jquery itself .

Also refer this answer and on server side you can use normal codeigniter cookie function it works fine for me.

Community
  • 1
  • 1
Sathya Raj
  • 1,051
  • 2
  • 10
  • 29
0

Or you can add cookie helper to autolod -> applications/config/autoload.php

$autoload['helper'] = array('cookie');

if you use autoload you don`t need to load it manualy each time when you need it!

$this->load->helper('cookie');
0

Simple

$.cookie('the_cookie');

Sohail Anwar
  • 304
  • 1
  • 5
  • 16
0

the issue solved out . i tried to add cookie via jquery which has different encryption from codeigniter. the issue solved out when i tried to using normal $_COOKIE[] . there i eliminated encryption issue.

Roo
  • 618
  • 1
  • 8
  • 17