Need help enabling session_start does not seem to be working properly??

Posted on 2006-05-01
Last Modified: 2013-12-12
I have a login page that should check to see if the user is authenticatedor logged in when the user clicks 'My Account' button but it is just reloading the login page even though in the top left corner of the page it shows user is logged in.  

What should happen is it check of there is a session variable and if so take that user to his account info.  if not it should load the login.php page

Can you look at the code to see whats going on...dont quiet understand what going on in this login form.


// *** Validate request to login to this site.

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $_SESSION['PrevUrl'] = $accesscheck;

if (isset($_POST['username'])) {
  $MM_fldUserAuthorization = "login_check.php";
  $MM_redirectLoginSuccess = "memberindex.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_myconn, $myconn);
  $LoginRS__query=sprintf("SELECT id,email,name, password FROM members WHERE email='%s' AND password='%s' and active = 'Yes' ",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
  $LoginRS = mysql_query($LoginRS__query, $myconn) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
        //admin type
     $loginStrGroup = "MEMBER";
      $array = mysql_fetch_assoc($LoginRS);
      //$GLOBALS['memberID'] = $array['id'];
      //$GLOBALS['memberName'] = $array['name'];
    //declare two session variables and assign them
   // $GLOBALS['MM_Username'] = $loginUsername;
   // $GLOBALS['MM_UserGroup'] = $loginStrGroup;      
    //register the session variables
      $_SESSION['MM_Username'] = $loginUsername;
      $_SESSION['MM_UserGroup'] = $loginStrGroup;
      $_SESSION['memberID'] = $array['id'];
      $_SESSION['memberName'] = $array['name'];

      mysql_query('update members set last_login = NOW() where id = '.$array['id'],$myconn) or die(mysql_error());
    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];      
    header("Location: " . $MM_redirectLoginSuccess );
  else {
    header("Location: ". $MM_redirectLoginFailed );
<FORM ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" >
Question by:mnoel76
    LVL 16

    Accepted Solution

    you should start as seesion
    // *** Validate request to login to this site.

    Author Comment

    dr dedo....thanks for the response.  I tried that but it didn't give me the result I was looking for.  I did find a work around which basically looks to see if there is a session variable and dependent on if there is or is not....the user then when he  clicks the my account will take him to the correct page.  As opposed to loading the login page.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now