Jump to content

session and cookies...


The14thGOD

Recommended Posts

Not sure what's up, but basically I am getting no session or cookies... (cookies are enabled)

Here's the log in script.

 

<?php
session_start();
import_request_variables('pg');
if(empty($required)){ //spam field = required, if its filled, its spam
	include('../includes/connect_db.php');
	$query = "SELECT * FROM challenge_users WHERE username=LOWER('".mysql_real_escape_string($username)."') LIMIT 1";
	$result = mysql_query($query);
	if(mysql_num_rows($result) != 0){
		$row = mysql_fetch_assoc($result);					
		//password manipulation here	

		if($secure_pass == $row['password']){
			//also set session incase user doesnt accept cookies
			setcookie("cotw","$row[username];$secure_pass;$row[name];$row[email]");
			$_SESSION['username'] = $row['username'];
			$_SESSION['password'] = $row['password'];
			$_SESSION['name'] = $row['name'];
			$_SESSION['email'] = $row['email'];
			//$data = explode(';',serialize($_COOKIE['cotw']));

			//chk the database to see if the current challegne is completed, return value in array
			//so that the js doesn't show the wrong message/form if it is
			$chk_query = "SELECT completed FROM challenge_challenge WHERE the_date='".mysql_real_escape_string($the_date)."' LIMIT 1";
			$chk_result = mysql_query($chk_query);
			$chk_row = mysql_fetch_assoc($chk_result);

			//encode in json
			//send this info back so JS can use it
			$json = array('error'=>0,'name'=>$row['name'],'email'=>$row['email'],'username'=>$row['username'],'pass'=>$secure_pass,'completed'=>$chkrow['completed']);
			//echo mysql_error();
			echo json_encode($json);
		}else{
			//encode in json
			//send this info back so JS can use it
			$json = array('error'=>1,'errors'=>'user/pass');
			//echo $secure_pass;
			echo json_encode($json);
		}
	}else{
		$json = array('error'=>1,'errors'=>'user/pass');
		echo json_encode($json);
	}
}
?>

I know sessions work on this server, I use them for a different site on the same server.

 

Once I figure out why I have no sessions or cookies, the rest of the scripts that are based on those should work too =P.

Any and all help is greatly appreciated.

Justin

 

**edit

I should note that it sends all the variables just fine in the response.

Link to comment
https://forums.phpfreaks.com/topic/196504-session-and-cookies/
Share on other sites

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.