Jump to content

really stupid question but i can't figure it out


acidglitter

Recommended Posts

At the very top of my login page it shows this

<?php
session_start();
header("Cache-control: private");
if ($_SESSION['peachy']){
header("Location: ...");
exit();
}

 

so if you're already logged in, you don't have to login again, and that works perfectly. But when it forwards to the next page (which is in a different folder), it says you're not logged in.

 

This is the current code at the very top of the 2nd page

<?php session_start();
header("Cache-control: private");
if(!isset($_SESSION['peachy'])){
echo "you're not logged in";
exit();
} ?>

 

I tried copying the one from the other page, but for some reason it won't work on this page. It worked earlier today but now it won't. I can't figure out whats wrong  >:(

 

I think somehow the session is lost..

Its an html form and the 2nd page shows this..

<?php if(isset($_GET['p'])){
$word=md5($_POST['word']); $where="..";
$chpass=mysql_query("SELECT pass FROM info WHERE pass='$word'");
if(mysql_num_rows($chpass)>0){
	$_SESSION['peachy']="yes";
	$_SESSION['tableid']="$thesessionid";
	header("Location: $where");
} else {
	echo "Wrong password..<p>";
}
} ?>

Yep, on the login page and the 2nd page I have session_start() at the top. Everything has been working for months. And then I decided the username part was pointless for this so I deleted it from the info table and the login page, and since then it stopped working.....

Not sure if my post would be of any help. But just try some changes in your code

<?php if(isset($_GET['p'])){
        $_SESSION['peachy']= false;
$word=md5($_POST['word']); $where="..";
$chpass=mysql_query("SELECT pass FROM info WHERE pass='$word'");
if(mysql_num_rows($chpass)>0){
	$_SESSION['peachy']= true;
	$_SESSION['tableid']="$thesessionid";
	header("Location: $where");
} else {
	echo "Wrong password..<p>";
                $_SESSION['peachy']= false;
}
} ?>

 

and then to check if your login is correct do this

<?php 
session_start();
header("Cache-control: private");
if(!$_SESSION['peachy']){
echo "you're not logged in";
exit();
} ?>

Just try this. It might work  :)

I fixed the problem. It was all because on the login page, where it says header("Location: $where");, the $where address was http://mysite. When I changed it back to http://www.mysite it worked again.. Why would that tiny difference stop all of this from working?  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.