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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.