Something weird with sessions happening
Moderator: General Moderators
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
Something weird with sessions happening
I have a user based site using session. It is acting really weird when i first log in using sessions it takes me to mypage which is a page that you get when first logged in. Then when i click on another page that requires sessions it goes back to the login page and asks me to login again so i do. Then everythign works fine from that point on until i close my browser or log out and have to log back in.
Any ideas?
thank you
Anthony
Any ideas?
thank you
Anthony
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
My sessions are called first thing on the page.
sat: what do you mean an over right? See after i login for the 2nd time, i can view any page and never have a problem again. But i always have to login twice. I know for 100% fact it sets the session even the second time. But get this. It only requires you to login again if your this is the first time your the browser that is open has been on the page. else it always works even after the user logs out.
Any other ideas? Here is my login code..
And here is the code that is called on the top of the first page it views (mypage)
and this is the code called at the top of mypage
Thank you again
sat: what do you mean an over right? See after i login for the 2nd time, i can view any page and never have a problem again. But i always have to login twice. I know for 100% fact it sets the session even the second time. But get this. It only requires you to login again if your this is the first time your the browser that is open has been on the page. else it always works even after the user logs out.
Any other ideas? Here is my login code..
And here is the code that is called on the top of the first page it views (mypage)
Code: Select all
<?php
$con = mysql_connect("localhost","pinehead","") or die(mysql_error());
$db = mysql_select_db("pinehead",$con) or die(mysql_error());
$lastlogon = date("l, M, d");
$pass = md5($pass);
$sql = "SELECT * FROM users where user='$uname' and pass='$pass'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row["user"] == $uname && $row["pass"] == $pass) {
$lastlogon = date("l, M, d");
session_start();
$_SESSION['name'] = $_POST['uname'];
if(isset($_SESSION['name'])) {
$sqll = "UPDATE users SET last_logon='$lastlogon' WHERE user='".$_POST['uname']."'";
if(mysql_query($sqll)) {
header("location: http://www.kc.com/mypage");
}
else {
echo "Couldn't update user<br />".$sqll."<br />".mysql_error()."";
}
}
else {
echo "Couldn't Set User Session";
}
}
else {
$output = "<center><font face=arial size=-1 color=red>Username/Password do not match <a
href=loginbox.php>Click here to login again</a></font></center>";
include('html.inc.php');
start_header($output);
}
?>Code: Select all
<?php
require('html.inc.php');
user_check();
and user check is located in html.inc.php and is as follows
function user_check() {
if(!isset($_SESSION['name'])) { header("Location: http://www..com/loginbox.php"); exit; }
?>- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
require('html.inc.php');
user_check();
and user check is located in html.inc.php and is as follows
function user_check() {
if(!isset($_SESSION['name'])) { header("Location: http://www..com/loginbox.php"); exit; }
?>Code: Select all
<?php
//and user check is located in html.inc.php and is as follows
function user_check() {
if(!isset($_SESSION['name'])) { header("Location: http://www..com/loginbox.php"); exit; }
require('html.inc.php');
user_check();
?>-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
pinehead18
- Forum Contributor
- Posts: 329
- Joined: Thu Jul 31, 2003 9:20 pm