0

I have looked around on Stack Overflow and many other sites for a solution to my problem but still no solution has come and I don't even get how my problem is even possible. The question is at the bottom of the post.

Here are the contents of login.php:

include("loginFunctions.php");
include("databaseFunctions.php");

if(checkSession())
{
    header("location: adminArtist.php");
    exit();
}

Here are the contents of loginFunctions.php:

function checkSession()
{
$isOnLine = false;
session_start();
if(isset($_SESSION["online"]))
{
    $isOnLine = true;
    session_regenerate_id(true);

}
else
{
    endSession();
}
    return $isOnLine;
}

Here are the contents of adminArtist.php:

include("loginFunctions.php");
if(!checkSession())
{
    header("location: login.php");
    exit(); 
}

Here's the problem I have: When I login I get to the adminArtist page, so that means $_SESSION["online"] = true in both login.php and adminArtist.php. However, when I hit the submit button or press F5 or reload the page in any other way, it sends me back to login screen. This is probably because all of a sudden the $_SESSION["online"] has become false.

What do I have to do to keep the value as true?

I was not sure how much code I needed to post, but I think this should be enough to locate what I have done wrong. Otherwise I will edit and add more.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
Vollan
  • 1,887
  • 11
  • 26
  • Try adding session_start(); to all the pages past the initial login page just inside the opening – MrTechie Apr 07 '15 at 06:13
  • First try to use session_start on each page at top just under – Alive to die - Anant Apr 07 '15 at 06:13
  • I tried on multiple locations to put the session time to 3600, both when login was made, when adminartist was loaded and in the checkSession function. neither worked. So not sure if im doing it right. – Vollan Apr 07 '15 at 06:32
  • 1
    Please edit your post to contain the relevant code from _login.php_ which would set the value for `$_SESSION` and any redirect code, output linking to _adminArtist.php_, etc... – Sᴀᴍ Onᴇᴌᴀ May 11 '17 at 19:10
  • Thank you for your effort with editing and help Sam Onela, however this project is outdated and i should have deleted it a long time ago. – Vollan May 11 '17 at 19:14

0 Answers0