Reputation: 595
I have code, echo shows nothing?? Why
<?php
$szukane = $_POST['szukane'];
$tablica = Array('a' => 'az', 'b' => 'sx');
setcookie('tablica', serialize($tablica));
$un_tablica = unserialize($_COOKIE['tablica']);
echo $un_tablica['a'];
?>
Upvotes: 1
Views: 58
Reputation: 595
I have to change this:
$un_tablica = unserialize($_COOKIE['tablica']);
for this:
$un_tablica = unserialize(StripSlashes($_COOKIE['tablica']);
Upvotes: -1
Reputation: 33163
From the manual:
Common Pitfalls:
- Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires.
Upvotes: 6