Jump to content

Recommended Posts

Sorry if there are currently loads of topics, I'm not sure what I'm looking for atm so pardon me if this is a repeat topic of some sort.

 

Right I haven't been doing web design for at least a couple years due to ill health so I probably had this solution before but it's gone right out of my head right now lol

 

this is my code, but i'm not sure if this is correct for the subdirectories that i've currently got it in.

 

		$query = "SELECT rank, username, member_id FROM members WHERE (username='$u' AND password='$p')";
	if($result = @mysql_query ($query))
	{
		list($rank, $username, $member_id) = mysql_fetch_array($result);

                        if($rank == '1')
                        {
			$redirect_url = $_POST['direction'];
        	                if(isset($_POST['v3_cookies']))
			{
  					setcookie('username', $username, time()+60*60*24*30, '/', 'website.com', 0);
				setcookie('member_id', $member_id, time()+60*60*24*30, '/', 'website.com', 0);
			}
			else
			{
				$_SESSION['username'] = $username;
				$_SESSION['member_id'] = $member_id;
			}
			mysql_free_result($result);

              			ob_end_clean(); // Delete the buffer.
			header("location: /index.php");
			exit();
		}
		else
		{
			echo "<font style=\"color : #F00; font-weight : bold;\">NOTE:</font> You do not have permission to Access the Administration Area.";
		}
	}
	else
	{
                        $info[] = 'The Username and Password entered do not match those on file.';
		$info2[] = '<br /><br />Error: ' . mysql_error() . '<br /><br />Query : ' . $query;
	}

 

what is the right way of putting this bit of code when it's in a few subdirectories?

 

  					setcookie('username', $username, time()+60*60*24*30, '/', 'website.com', 0);
				setcookie('member_id', $member_id, time()+60*60*24*30, '/', 'website.com', 0);

 

thanks very much for reading, as previously mentioned it's been a while since I've done this and i'm getting a bit of a headache right now so can't think straight  :'(

Link to comment
https://forums.phpfreaks.com/topic/166861-sessions-cookies-and-subdirectories/
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.