Okay I have narrowed down the problem.
The problem is that the value does not get set when the page is unloaded.
Here is what I have done.
the reason why you see php code there is because i could not get it to work with jQuery.
Anyway, when I try to reset the value of the cookies in a different page it does not work but it works on the first page main.php my landing page I have a viable counter and it is set to the cookies value if the cookie exists but if it does not exist then start at 0.
when the user navigate away from main.php to tab1.php the value of the counter is stored in the cookies no problem. (assume that they spend 15 seconds on main.php)
in my tab1.php page I have the same counter and code but it is invisible counter. (assuming the user spent 10 seconds at tab1.php)
When the user navigate back to main.php page the counter startsat 15 seconds and not at 25 which is should.
So the second tab does not store the cookie that it is already created. cookies can be re-set by a different page from the one which was created, right?
- $(window).on('unload', function() {
- $.jCookie('callTimer', $('#timer').val() );
- //console.log('unload ' + $.jCookie('callTimer'));
- });
-
-
-
-
- $('#timer').runner(
- {
- autostart: true,
- milliseconds: false,
- startAt: <?php if( isset($_COOKIE['callTimer'])) echo convertTimeToSeconds($_COOKIE['callTimer']) * 1000; else echo 0; ?>
- }
- );