adv Posted December 13, 2007 Share Posted December 13, 2007 helllo my problem is : i use curl to grab some words from a page if ($result) { preg_match('/<span><strong>(.*?)<\/strong><\/span><br><br>/', $result, $al); if(count($al) != 0) { $nume = $al[1]; $nume1=$nume; setcookie("incoming",$nume1,time()+3600); } } it worked and it grabed the word i needed and now on another page with $_cookie i posted but the problem is it not loads directly <?php $in22=$_COOKIE['incoming']; echo $in22; but it not loading with the page it works only if i refresh the page or click the submit button then the word apears how do i do it to load with the page and when the page apears the word will apear Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 13, 2007 Share Posted December 13, 2007 yeah learn to explain better... if you set a cookie, you cannot instantaneosly echo it afterwards, you can only echo it after another page load, so it can properly read the cookie you just wrote cookies aren't ajax and are not asynchronous, they are injected & included in your header, which changes every page load, so if you have a header with no cookie and then create a cookie on that page load which had just loaded with no cookie, how can you expect to access the cookie? you can't! you can only access cookies that have been stated in the header..etc.. short story, set the cookie in a previous page load, so when it comes time to use it, you can use it or if you want to instantaneously use it, refer to the value you just assigned to the cookie, rather than trying to call the cookie immediately Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.