archipuir
12-20-2010, 05:01 PM
Hello,
I have a login page that redirects to my second page after login. The session is created in the login page. In my second page I need to check if there is a valid session, without creating a new one. Is it possible to check it, without adding session_start() in my second page, so that no new session is created?
Here is the code of my login page:
<?php
session_start(); // Creates a session
$_SESSION["username"] = $username;
header("Location: secondpage.php");
?>
Here is the code of my second page:
<?php
session_start(); // How can I remove this line, so that it doesn't create a new session?
if (isset($_SESSION)) {print "session exists";} // Checks if session exists
else {print "session does not exist";}
?>
I have a login page that redirects to my second page after login. The session is created in the login page. In my second page I need to check if there is a valid session, without creating a new one. Is it possible to check it, without adding session_start() in my second page, so that no new session is created?
Here is the code of my login page:
<?php
session_start(); // Creates a session
$_SESSION["username"] = $username;
header("Location: secondpage.php");
?>
Here is the code of my second page:
<?php
session_start(); // How can I remove this line, so that it doesn't create a new session?
if (isset($_SESSION)) {print "session exists";} // Checks if session exists
else {print "session does not exist";}
?>