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 4103218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:55:49+00:00 2026-05-20T20:55:49+00:00

I am trying to set up a login system for my website that requires

  • 0

I am trying to set up a login system for my website that requires someone to be logged in in order to post. I have set it up with sessions and it works great on my localhost but not on the server. I set up print_r(session) on some of the pages to see where the data loss is. On the page checklogin.php, which is the page that gets run when someone logs in, it works fine. Here is some code from there:

<?php
session_name('login_session');
session_start();

mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("date_ideas") or die(mysql_error());

$uname=$_POST['uname'];
$uname=mysql_real_escape_string($uname);
$pass=$_POST['pass'];
$pass=mysql_real_escape_string($pass);
$pass=md5($pass);

$query="SELECT * FROM users WHERE uname='$uname' AND pass='$pass'";

$result=mysql_query($query) or die(mysql_error());

$numrows=mysql_num_rows($result);

echo $numrows;

if ($numrows==1)
{
$_SESSION['login']="1";
$_SESSION['uname']=$uname;
echo "<script type='text/javascript'>alert('match');</script>";
print_r($_SESSION);
}
else
{
$_SESSION['login']="";
echo "<script type='text/javascript'>alert('Invalid Login');</script>";
echo "<script type='text/javascript'>window.location = 'login.php?uname=$uname'</script>";
}
?>

When I submit the form with good login information, the alert pops up and the print returns:

Array ( [login] => 1 [uname] => FrizbeeFanatic14 )

So at that point it’s working. However, when I go to the main page, the print becomes:

Array ( )

So it has lost the session information. Here is the code from the main page:

<?php
session_name('login_session');
session_start();
?>
<html>
<head>
<title>Great Date Ideas</title>
<link rel="stylesheet" type="text/css" href="mainstyle.css" />
<script type="text/javascript" src="validate.js"></script>
<script type="text/javascript" src="cookiecheck.js"></script>
</head>
<body onload="checkCookie()">
<script type="text/javascript">
if (detect=false)
{
document.write("You must enable cookies to view this page.");
window.stop();
document.execCommand('Stop');
}
</script>
<div id="home"><?php require("header.php");?></div>
<?php
print_r($_SESSION);
mysql_connect("localhost","root","root") or die(mysql_error());
mysql_select_db("date_ideas") or die(mysql_error());

$result=mysql_query("SELECT * FROM ideas ORDER BY post_date DESC") or die(mysql_error());

It goes on, but what follows works fine.

So all this code works just fine on my localhost, but on the server I get this error.

  • 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-20T20:55:50+00:00Added an answer on May 20, 2026 at 8:55 pm

    I found the problem – the save directory for the PHP sessions was a root apache directory, and I’m runnin nginx fastcgi. I just changed the root permissions for the folder and it works. Thanks a ton for all of your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up a login system that checks a mysql db validating username,hashed
I'm trying to build Facebook OAuth into my existing Authlogic login system. I have
Im trying to set up a Devise Authenticable LDAP login system. Right now, I
Trying to set a flag in the post to allow processing or not. The
Short Working on login system and trying to implement remember me feature. Recently, l
I have a website that's working with Facebook Connect (or Facebook for Websites as
I'm trying to implement a simple login system in Rails, but when I try
I'm trying to set up forms authentication across multiple servers and subdomains. I have
I have been trying to set up a PHP based SOAP client to connect
I am trying to integrate my custom user system with Wordpress, and I have

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.