Let's say I have a user/pass to enter and once it's entered another page will be redirected and in that profile page will show a line sayingi you have been staying here for xxx seconds.
I am new in PHP MySQL I have website called itube.one I already created login/register system. I need some tutorials or sothing showing exactly what i want i cant fit this script to my site I am using PHP 5.6
session_start();
if(!(isset($_SESSION["username"])))
{
header("location: index.php");
}
else
{
echo "Welcome " . $_SESSION["username"] . "<br/>";
echo "You have been logged in for " . $_SESSION["timeLogged"] . " seconds.";
}
Looking at your code I assume that in your login code you are setting this:
$_SESSION['timeLogged'] = time();
Then in your subsequent pages you can use this:
$timeSinceLogged = time() - $_SESSION["timeLogged"];
echo "You have been logged in for " . $timeSinceLogged . " seconds.";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With