Jump to content

PHP check $_SESSION for real user


jamesxg1

Recommended Posts

I dont know if the title is rightly described,  But i need some sort of PHP statment (Would probablly be a IF statment) that willl check the $_SESSION['username'] and match it to a page eg. if the user is on There profile it will show them a specific menu ?,

 

How do i do this i have this so far

 

<?php
	if(isset($_SESSION['username']))
	{
		if($_SESSION['username'] == "$_SESSION['username']")
		{
	?>

Link to comment
https://forums.phpfreaks.com/topic/142846-php-check-_session-for-real-user/
Share on other sites

if(isset($_SESSION['u'])) {

Select whatever is related to the the value of $_SESSION['u'] in your database and present it.

Make sense?

 

 

 

 

Hiya,

 

I understand the $_SESSION part but whats the ['u'] for ?

 

and nah i dont understand do u mean show the menu after this IF statment ?

I understand the $_SESSION part but whats the ['u'] for ?

 

I use u instead of user_name. Lazy typer!!

 

<?php
if(isset($_SESSION['u']))
{
$query = "SELECT whatever FROM table WHERE user_name = '{$_SESSION['u']}'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo $row['whatever']
////etc etc being the  fields in your database that you want
}else{
echo 'No session set for you. Go login';
}
?>

 

 

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.