- Impact
- 38
Hey,
I am having a problem with sessions, I am failing to see how and why it is not working, I am doing everything exactly the same as usual.
.
login.php (page with login form)
log-functions.php (does the logging in)
/app/index.php (page being sent to after login)
Right, simply, I am creating a new session, setting ['oams'] to 1 (or whatever I want), and when it sends me to /app/index.php it kicks in saying that $_SESSION['oams']) is not set, thus sending me back to the main index page.
If i echo $_SESSION['oams']) in my log-functions.php file, it works fine, it seems to empty/lose my session data when it moves page.
If I remove the check for it being set, it lets me go to the right page, so something is wrong with the session starting or continuing when a page changes.
Anyone know a reason for this?
Thanks
I am having a problem with sessions, I am failing to see how and why it is not working, I am doing everything exactly the same as usual.
login.php (page with login form)
Code:
...
<form class="centered_200" method="post" action="app/include/log-functions.php">
<h2><img src="http://www.namepros.com/images/username.jpg" alt="Username" /></h2>
<input type="text" value="username" name="loginname" />
<h2><img src="http://www.namepros.com/images/password.jpg" alt="Password" /></h2>
<input type="password" value="password" name="passkey" />
<input type="hidden" value="login" name="request" />
<p><input class="loginbutton" type="submit" value="Login" /></p>
</form>
...
log-functions.php (does the logging in)
Code:
...
if($var=="login"){
session_start();
$_SESSION['oams'] = 1;
header('Location: ../index.php'); /** sends user to /app/index.php */
}
...
/app/index.php (page being sent to after login)
Code:
require_once('./config/settings.php');
require('./include/functions.php');
require('./include/db.php');
$con = new db();
session_start();
if(!isset($_SESSION['oams'])){header('Location: ../index.php'); exit;} /** THIS IS MY PROBLEM LINE */
$this->display();
Right, simply, I am creating a new session, setting ['oams'] to 1 (or whatever I want), and when it sends me to /app/index.php it kicks in saying that $_SESSION['oams']) is not set, thus sending me back to the main index page.
If i echo $_SESSION['oams']) in my log-functions.php file, it works fine, it seems to empty/lose my session data when it moves page.
If I remove the check for it being set, it lets me go to the right page, so something is wrong with the session starting or continuing when a page changes.
Anyone know a reason for this?
Thanks
Last edited:





