Welcome Guest, Not a member yet? Register   Sign In
cookies meet $this->uri->segment()
#1

[eluser]Julia Yan[/eluser]
--------first URL
index.php/category/index/table_1

if (!isset($_COOKIE['table'])) setcookie("table", $this->uri->segment(3));

echo 'cookie = '.$_COOKIE['table'] //show cookie = 'table_1'

...list

--------second URL
index.php/category/index/10 //10 is pages

echo 'cookie = '.$_COOKIE['table'] //show cookie = 10

---------when $_COOKIE['table'] changed??? I need keep first $this->uri->segment(3) into cookeis
#2

[eluser]InsiteFX[/eluser]
What are you talking about? Makes no sense.

InsiteFX
#3

[eluser]Julia Yan[/eluser]
[quote author="InsiteFX" date="1290945007"]What are you talking about? Makes no sense.

InsiteFX[/quote]

I tried to keep table name from first URL,
Then it been auto changed from other link such as list pages

How can I keep cookies value from first $this->uri->segment() ?
#4

[eluser]InsiteFX[/eluser]
You can also pass the cookie value as an array!

Or use a second cookie for the page!

Or better yet store the values in the database session user_data

InsiteFX
#5

[eluser]Julia Yan[/eluser]
---------Thanks InsiteFX

You can also pass the cookie value as an array!
a) all of cookies value updated automatically from last $this->uri->segment()

Or use a second cookie for the page!
a) same as above

Or better yet store the values in the database session user_data
a) how to expired auto when the browser closes

Q why cookies could not run normally at CI?
#6

[eluser]InsiteFX[/eluser]
Use an array, you will need to code to work right!
Code:
$cookie_data = array();

$cookie_data['table'] = $this->uri->segment(3);
$cookie_data['page'] = $this->uri->segment(3);

The problem is your over-writing the cookie table variable!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB