pixeltrace Posted April 18, 2007 Share Posted April 18, 2007 guys, i need help. i have a problem with session. it seems that its not working i have a page that uses session, on the first time you load the page everything is working fine i even used print_r to see the session values but if you refresh the page, its changing the session values with the values of the ones with the latest id in my database hope you could help me solve this problem below is the code for my page <? session_start(); if (session_is_registered("username")){ $username = $_SESSION['username']; $user_level = $_SESSION['user_level']; print_r($_SESSION); //$username = $_POST['username']; include 'db_connect.php'; $query = mysql_query("SELECT userid, username, first_name, last_name, job_title, email, user_level FROM admin_user WHERE username= '$username'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $userid = $row["userid"]; $username = $row["username"]; $first_name = $row["first_name"]; $last_name = $row["last_name"]; $job_title = $row["job_title"]; $email = $row["email"]; $user_level = $row["user_level"]; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>:: JobHiRings :: Administration Page</title> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 10px; margin-right: 0px; margin-bottom: 0px; } --> </style> <link href="css.css" rel="stylesheet" type="text/css"> </head> <body> <table width="778" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" background="images/headerbg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="226" align="left"><img src="images/header.gif" width="226" height="148"></td> <td> </td> </tr> </table></td> <td background="images/headerbg.gif"><img src="images/headeright.gif" width="16" height="148"></td> </tr> <tr> <td width="16" rowspan="2" align="left" valign="top" background="images/left.gif"><img src="images/left.gif" width="16" height="14"></td> <td width="745" valign="top"><table width="746" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3" class="text4">CMS USER MANAGER</td> </tr> <tr> <td colspan="3" align="right"> </td> </tr> <tr> <td colspan="3"><img src="images/spacer.gif" width="10" height="6"></td> </tr> <tr> <td width="224" valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> <td width="214" valign="top"><? include 'sidemenu.php'; ?> </td> <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td> </tr> <tr> <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td> </tr> </table></td> <td colspan="2" align="center" valign="top"> <iframe id="usermngr" src="user/view.php" width=730 height=400 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe></td> </tr> <tr> <td colspan="3"> </td> </tr> </table></td> <td width="16" rowspan="2" align="right" valign="top" background="images/right.gif"><img src="images/spacer.gif" width="1" height="1"><img src="images/right.gif" width="16" height="14"></td> </tr> <tr> <td valign="top"><img src="images/spacer.gif" width="746" height="10"></td> </tr> <tr> <td background="images/footerbg.gif"><img src="images/footerleft.gif" width="16" height="43"></td> <td background="images/footerbg.gif"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="10" colspan="2" align="left"><img src="images/spacer.gif" width="12" height="10"></td> </tr> <tr> <td width="746" align="center" valign="top" class="footer">Copyright © 2007 www.jobhirings.com. All Rights Reserved</td> </tr> </table></td> <td background="images/footerbg.gif"><img src="images/footeright.gif" width="16" height="43"></td> </tr> </table> <? }else{ echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/47581-help-on-_session/ Share on other sites More sharing options...
shaymol Posted April 19, 2007 Share Posted April 19, 2007 Hi mates as far as i know from php manual is below : If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister(). You can try with isset() . Thanks ShaymoL Quote Link to comment https://forums.phpfreaks.com/topic/47581-help-on-_session/#findComment-233079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.