Jump to content

[SOLVED] post problem


adv

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/81481-solved-post-problem/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/81481-solved-post-problem/#findComment-413665
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.