session id ISSUE?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cyandi_man
Forum Newbie
Posts: 12
Joined: Sun Nov 02, 2008 10:47 am

session id ISSUE?

Post by cyandi_man »

When using the session start code for my clnt login pages - it seems that it does not carry over to the next page once in the member section.

after logging in - i see the proper clnt info on the main profile page - however when i click to view another clnt page - my browser takes me to the login page which is the page i coded the user to go to if credentials are not saved.

please look at my code and let me know if anything is wrong. thanks!


this is the php file that is loaded once logged in, this page directs you to the proper verson depending on which browser you are using:


Code:

<?
session_start();
$_SESSION['logname']= $user;
$clientN = $_SESSION['client'];
$me = $_SESSION['name'];
$me2 = $_SESSION['name2'];
if (@$_SESSION['auth']!="yes")
{
header("Location: ../personal_account_login.php");
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function detectBrowser()
{
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer")
{
window.location = ("http://provicanhealth.com/code/FAMPROFILE_EX.php");
}
else
{
window.location = ("http://provicanhealth.com/code/FAMPROFILE.php");
}
}
</script>
<title>ProviCan.com</title>
</head>
<body onload="detectBrowser()">
</body>
</html>
at the begining of each page i placed the session start as follows:


Code:
<?
session_start();
$_SESSION['logname']= $user;
$clientN = $_SESSION['client'];
$me = $_SESSION['name'];
$me2 = $_SESSION['name2'];
if (@$_SESSION['auth']!="yes")
{
header("Location: ../personal_account_login.php");
exit();
}
bmoyles0117
Forum Newbie
Posts: 22
Joined: Sun Nov 02, 2008 1:46 am

Re: session id ISSUE?

Post by bmoyles0117 »

The session_start() needs to be at the top of every single page that requires the session. NOT just when the session variables are initialized.
cyandi_man
Forum Newbie
Posts: 12
Joined: Sun Nov 02, 2008 10:47 am

Re: session id ISSUE?

Post by cyandi_man »

bmoyles0117 wrote:The session_start() needs to be at the top of every single page that requires the session. NOT just when the session variables are initialized.
yes i have done that on every page - which is why i am not sure why it is not working?
any other suggestions?
any suggestions why it works for IE and not Mozilla?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: session id ISSUE?

Post by s.dot »

do print_r($_SESSION) to see if the session variables are set. I reckon they are.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply