soweb Posted October 28, 2014 Share Posted October 28, 2014 Hi All I am hoping someone can help. I am trying to create a session based on when the users first enters the page. This will capture the timestamp and retain that as the starting point for the countdown so even if the user goes away from the page and comes back, the timestamp does not reinstantiate itself. Can anyone give me some guidance please? Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/ Share on other sites More sharing options...
MDCode Posted October 28, 2014 Share Posted October 28, 2014 It all really depends on what kind of timestamp you want. <?php session_start(); if(!isset($_SESSION['start_time'])) $_SESSION['start_time'] = time(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495007 Share on other sites More sharing options...
soweb Posted October 28, 2014 Author Share Posted October 28, 2014 If you refresh the page the $_SESSION['start_time'] time changes when you echo it out Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495039 Share on other sites More sharing options...
Barand Posted October 28, 2014 Share Posted October 28, 2014 Then your code isn't what SocialCloud posted Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495043 Share on other sites More sharing options...
soweb Posted October 28, 2014 Author Share Posted October 28, 2014 its exactly the same just with echo $_SESSION['start_time']; Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495044 Share on other sites More sharing options...
Barand Posted October 28, 2014 Share Posted October 28, 2014 Are you setting the value of $_SESSION['start_time'] somewhere else in the script then? Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495053 Share on other sites More sharing options...
ginerjm Posted October 28, 2014 Share Posted October 28, 2014 You do have the ! character there, yes? Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495054 Share on other sites More sharing options...
mac_gyver Posted October 29, 2014 Share Posted October 29, 2014 and assuming that the session_start() is actually working. do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would be reporting and displaying all the errors it detects, such as session_start() errors? Quote Link to comment https://forums.phpfreaks.com/topic/292113-session-timestamp-capture-for-countdown/#findComment-1495117 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.