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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.