I need to get Cookie from pixel of facebook _fbp and _fbc
but if user enter first time on my page then I can't read the cookie with this 2 value
only if change page, navigate then I can read
I'm searching but I not have found solution
echo $_COOKIE['_fbp'];
echo $_COOKIE['_fbc'];
first time are empty
Related
My problem is cookie has been set with expiry time and in value there is no start or expire time etc but I want to get its start time mean when this cookie created?
Basically when user enters into my site and browse through some pages and reach on a specific page where cookie created, now it continuous browsing and reach on some other page where I just want to check is this cookie created within 5 hours or within 1 day etc.
I want this because user may leave site during process completion and come again after some time then I will check if user came in specific time so I want to reopen same page where he left.
Sorry if my english is not good.
There is no option available to get Cookie Creation date/time. Whenever user visits your site, You can simply add a variable + value([creation_datetime=>2016-06-10 10:10 AM]) in the cookie, and retrieve it whenever you want it.
Here is example
Example 1
Example 2
You can add current time in cookie value and check anytime when it was created (until it expires)
I make this post because I am really confused about session in PHP. I have a page (index.php) and I save in session a lot of variables (for example, one of this is $_SESSION["FID"]) and i redirect the user in a third party iframe. When the user enter successful his data in iframe, the iframe redirects the user again in index.php and also saves in session other variables.
When the user enters again in index.php I check the session, which comes from iframe (every time the session is set) and after that I make a check if $_SESSION["FID"] isset.
The problem is that most of the times (regardless the browser or something else), $_SESSION["FID"] is empty. Why is this happening? How can I find a solution in this?
I 've tried to be clear and not to confuse you.
You must put session_start(); at the top of every page you want you $_SESSION data to exist.
I have a cookie set with expiry of 3 mins, this will allow a user to navigate through the site for 3 mins before seeing an advert. They will see the ad if cookie is not present on next page they visit and the cookie will be reset once the ad is closed.
However a consequence of this is that as soon as the website is visited the ad will show, how can I stop the ad showing on the first page a visitor lands on?
If you only want to use cookies: You can add another cookie to the site, set it to expire after the browser is closed, and only show the ad if this cookie is set but the other is not.
Alternatively use session like methods, like storing in a session the time the user has entered the page, and calculate when to show the ad from that time. This also means you have to check for the ad showing an other way (checking the value of the session variable), not via cookies.
I have a web php web site. I want to show a message on the pop up div when a user browse my site (home page). I need to show the message only the first time with in a browser.
Does anyone know?
There is no php in your question, it is only js and cookies.
The logic you want is:
Does cookie <name> exist?
yes
The user has been to your page/site before
do nothing
no
The user is new
write cookie <name> with any value
run your "display message" function
Basically, you can do this using two step action, using either sessions or cookies
Show the div
Check if a parameter is previously set
If not show the div
Then set a parameter to confirm it is never again, till the browser is closed
Since other answers are focused on cookies, I will give you an example of session.
session_start();
if(!isset($_SESSION['boxshowed']) || !$_SESSION['boxshowed'])) {
echo "<div>to show</div>";
$_SESSION['boxshowed'] = true;
}
Using sessions for this, will show the box again, when the user reopens the site, after completely closing it.
i think you need to set cookie for that in php and check if cookie value is set then don't show pop up message
I think you can open browser easily, but your question is it should be open only first time even user refresh or reload page it should not display again.
Every time page will load it will check if they have cookie?
If they have then they do nothing.
If they do not have, then display poup and set cookie.
this is you may have to do (use the cookie to store that data)
I'm looking for a way to time a visitors stay on a website, whilst not restarting or interrupting the timer when changing pages.
Store the initial visit time in a session value. Any future visits to the site use a secondary session variable to hold the last visited time and work out the time on your site from that.
Unless you use Ajax to update the session values the user could be active on your site (on the same page) for 20minutes but it would show up as a zero length visit.
Basic example:
<?php
session_start();
if(isset($_SESSION['firstVisit']))
$_SESSION['latestVisit'] = date();
else
$_SESSION['firstVisit'] = date();
echo $_SESSION['firstVisit'] . " - " . $_SESSION['latestVisit'];
?>
You can start a session the moment the user requests the first page. With the session you can track the user from page to page. so you could calculate the total time between the first and last page requst of their visit.
You should also be able to send an Ajax request on page unload, thereby you could detect the time spent on a single page. However, if they browser in multiple windows/tabs, your reading is false, unless you are somehow able to detect page focus.
Combine the two and you should be able to get a quite complete picture.
store the data in the session, and save the data when the user performs logout
(if the user does not logout it will not be saved, but that should not be a problem)
edit: if the users does not login/logout, you have to catch when the session dies and save the data then. when evaluating the data you have to compensate for how long the session lives before it dies, e.g. 5 mins or whatever, and subtract it. will give you a ballpark figure, not exact time the user looked at the site.
You can track the time for which the user was logged in, but if you want the amount of time (a non logged in) user stays, I dont think it is possible, as there are a lot of ways to move from one page to another