Reloading but keeping the sessions

54 Views Asked by At

I have made a simple Student Management system using php, JavaScript and CSS. I want to be able to reload the php pages within my system but keep the php sessions that I have set.

Any Solutions?

Here is a snippet of code from a php page. I made a button to go back to the previous page.

<html>
<button class= "submit" onclick="GoBack();">Back To Home Page</button>
</html>

I searched on the internet for a bit and tried to use the event.preventDefault method. It did not work.

`<script>
function GoBack(event,inputText){
window.location="AdminHomePage.php";

event.preventDefault();
}
</script>`

Any Solutions?

I made a login Page in this system and connected it to a database in HeidiSQL using MySQL.

The program checks if these values entered in the login page is in the database. If it is, it is put in a associative array.

if ($num == 1) {

        $d = $rs->fetch_assoc();

        $_SESSION["t"] = $d;
1

There are 1 best solutions below

0
Ved_ramaujan On

PHP sessions belong to the server side. Even if you reload a page, the session is maintained.

If you are losing session data on reload, you need to debug your code that starts the session and stores the data into it.