kpetsche20 Posted November 20, 2008 Share Posted November 20, 2008 I added a row to the database where the session are made (table users). I added a column bonus, however, it does not create the sessions. When I login the session is made for the ID, but nothing else. Here is the code I have. function check_login($login, $password) { $sql = "SELECT * FROM users WHERE login='".$login."' AND password='".md5($password)."'"; $result = mysql_query($sql); $num = mysql_num_rows($result); $data = mysql_fetch_array($result); if ($num == 1) { session_start(); $_SESSION['last_access']=time(); $_SESSION['function']=$data['function']; $_SESSION['bonus']=$data['bonus']; $_SESSION['login']=$data['login']; $_SESSION['firstname']=$data['firstname']; $_SESSION['lastname']=$data['lastname']; $_SESSION['id']=$data['id']; return true; } else return false; } And here is the code to the index page where users login and the session is created. <? session_start(); $_SESSION=array(); session_destroy(); include("conf/conn.php"); include("conf/functions.php"); $sql_title = "SELECT * FROM settings WHERE id='1'"; $result_title = mysql_query($sql_title); $data_title = mysql_fetch_array($result_title); if (isset($_POST['loginbt'])) { if ($_POST['login'] != "" and $_POST['password'] != "") { if (check_login($_POST['login'], $_POST['password']) == true) { if ($_SESSION['function'] == 1) header('Location: admin/'); else header('Location: members/'); $error_login = ""; } else { $error_login = "wrong username/password <br />"; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Clever Shopper</title> <SCRIPT LANGUAGE="JavaScript" SRC="conf/functions.js"></SCRIPT> <link href="CSS/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style2 {font-family: Arial, Helvetica, sans-serif} body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } #wrapper {background-color:#FFFFFF;} --> </style> <!-- TradeDoubler site verification 1577957 --> </head> <body> <div id="wrapper"> <div id="header"><img src="images/clever-shopper-logo.gif" width="880" height="150" /> <div id="menu"> <a href="index.php"><img src="images/Home.gif" width="63" height="32" border="0" /></a><a href="index.php?p=about1"><img src="images/About.gif" width="74" height="32" border="0" /></a><a href="index.php?p=signup"><img src="images/Member.gif" alt="sign up" width="68" height="32" border="0" /></a><a href="index.php?p=stores"><img src="images/Stores.gif" alt="Stores A-Z" width="85" height="32" border="0" /></a><a href="index.php?p=cate&name=16"><img src="images/FreeCash.gif" alt="Easy Cash" width="83" height="32" border="0" /></a><a href="index.php?p=faq1"><img src="images/FAQ.gif" width="48" height="32" border="0" /></a><a href="index.php?p=contactus"><img src="images/Contact.gif" width="84" height="32" border="0" /></a> <div id="login"> <?php include 'menu/homepagelinks.php'; ?> </div> </div> </div> <div id="leftSidebar"> <div id="catMenu"><a href="index.php?p=myaccount"></a><?php $sql = "SELECT * FROM categories"; $query = mysql_query($sql); while($category = mysql_fetch_array($query)) { echo "<a href=\"index.php?p=cate&name=".$category['id']."\">".$category['name']."</a><br>"; } ?></div> <img src="images/Category-Side-Bar.gif" width="206" height="354" /> <div id="category"><img src="images/shopCategory.gif" width="147" height="23" /></div> </div> <div id="mainContent"> <?php if (isset($_GET['p'])) if (is_file($_GET['p'].".php")) include ($_GET['p'].".php"); else include ("home.php"); else include ("home.php"); ?> </div> <div id="rightSidebar"><img src="images/Right-Side-Bars.gif" width="206" height="708" /> <div id="recomend"><img src="../images/Recommend.gif" width="172" height="24" /></div> <div id="recommendText"> <p>Here at clevershopper we don't only reward you with cash back on your own purchases, we also give you the oportunity to earn cash on the purchases of the people you recomend to clevershopper. </p> <p>Just <a href="index.php?p=signup">sign up</a>, refer your friends and start earning today. To find out more about our referal system <a href="index.php?p=businessOpp">click here</a>.</p> </div> <div id="top10image"><img src="images/top5.gif" width="172" height="24" /></div> <div id="top10"> <p><img src="http://impgb.tradedoubler.com/imp?type(img)g(70586)a(1577957)" /></p> <p> </p> <p><img src="http://impgb.tradedoubler.com/imp?type(img)g(384203)a(1577957)" /></p> <p> </p> <p><img src="http://impgb.tradedoubler.com/imp?type(img)g(16994702)a(1577957)" /></p> <p> </p> <p><img src="http://impgb.tradedoubler.com/imp?type(img)g(16224284)a(1577957)" /></p> <p> </p> <p><img src="http://impgb.tradedoubler.com/imp?type(img)g(16652478)a(1577957)" /></p> </div> </div> <div id="footer"><img src="images/Footer.gif" width="880" height="100" /> <ul> <li><a href="index.php">Home</a></li> <li><a href="index.php?p=about1">About Us</a></li> <li><a href="index.php?p=tandc">Terms & Conditions</a></li> <li><a href="index.php?p=faq1">FAQ</a></li> <li><a href="index.php?p=contactus">Contact Us</a></li> <li><a href="index.php?p=businessOpp">Business Opp</a></li> <li><a href="#">Sitemap</a></li> </ul> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/133503-sessions-not-being-created/ Share on other sites More sharing options...
mtoynbee Posted November 20, 2008 Share Posted November 20, 2008 What does the page output when you write var_dump($data); and then var_dump($_SESSION); ? Link to comment https://forums.phpfreaks.com/topic/133503-sessions-not-being-created/#findComment-694379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.