Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6011443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:15:39+00:00 2026-05-23T02:15:39+00:00

SO this is the code for logging and and where I set things <?php

  • 0

SO this is the code for logging and and where I set things

<?php 
    session_start();
    $_SESSION['user'] = "kjkj";
    $_SESSION['pass'] = "";  
    $error = $user = $pass = "";

    if (isset($_POST['user'])) {
        $user = sanitizeString($_POST['user']);
        $pass = sanitizeString($_POST['pass']);

     if ($user == "" || $pass == "") {
            $error = "Not all fields were entered<br />";
     } else {
            $query = "SELECT store,c_pass FROM store
                    WHERE store='$user' AND c_pass='$pass'";

            if (mysql_num_rows(queryMysql($query)) == 0) {
                $error = "Username/Password invalid<br />";
            } else {
            $_SESSION['user'] = $user;
                $_SESSION['pass'] = $pass;
            $str = $_SESSION['user'] . ", You are now logged in. Please 
                       <a href='scheduler.php'>click here</a>.";

                die($str);
            }
        }
    } ?>

It’ll print the correct store name after the query and all that. But when I try to use it in another php file like this

if (!isset($_SESSION['user']) ) {
    die("<p><h1>Please Login</h1></p>");
} else {
    echo "<p><form id ='addemp' method=\"post\" action=\"addUser.php\">
          Name<input type=\"text\" name=\"emp\" />
      \"". $_SESSION['user'] . "\">
      <input type=\"submit\" value=\"AddUser\" />
    </form></p>";
}

It is an empty string. Not null just empty string. I tried all the solutions I can find on the internet, none of them worked. I’m out ideas as to why this isn’t working.
Any help will be greatly appreciated, thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:15:40+00:00Added an answer on May 23, 2026 at 2:15 am

    It could be a number of things. First of all do sessions work any other time?
    I don’t think you have provided enough information for us to help you. It could be a problem with set-up of apache/php not just your code. Has happened to me before when I was developing on Windows with WAMP and temp folder didn’t have correct permissions. As I said there could be many issues that cause your session to misbehave.

    • When you do a counter and refresh
      page does it keep a number?
    • At the
      beginning of every time that uses sessions you need to have
      session_start() method called.
      Important: There can’t be any echo’s or prints etc before
      session_start().
    • Put var_dump($user) before $_SESSION['user'] = $user; and check the content of $user before it gets saved. It could be that your sanitizing function is not working properly. Do it also at the end of the first script to see the content of $_SESSION to make sure variables are saved properly.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this week I'm having problems logging in LinkedIn using ruby mechanize. My code is
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
I need help with this code: #Set the starting directory to C:\Users Set-Location C:\Users\
This code in JS gives me a popup saying i think null is a
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We
This code does not seem to compile, I just need to write something to
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code is executed by many way. When it's executed by the form button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.