Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

$_Session Not Working

session

  • Please log in to reply
4 replies to this topic

#1 promehdioh

promehdioh

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 13 April 2012 - 01:23 AM

the session not working with me this morning ,I don't know why
look at the code:
<?php ob_start();
session_start();
?>
<html xmlns='http://www.w3.org/1999/xhtml'>
   <body>
	  <div class='container'>
	    <div class='header'>
	   <img src='../pictures/logo.png' />
   
	 </div>
     
	 <div class='corps' dir='rtl'>
    <?php   
	   include '../config/configdb.php';
    include '../api/usersapi.php';
    if(isset($_POST['user']) && $_POST['user'] == 'login'){
	
			 $username = strip_tags($_POST['username']);
		   $password = strip_tags(sha1($_POST['password']));
    if($username && $password){
	 $getuser = tutofilter_users_get("WHERE `username` = '$username' AND `password` = '$password'");
	 if($getuser == NULL)
	    echo 'no member with this name ';
	 else{
	  foreach($getuser as $user):
		  $uname = $user->username;
	   $upass = $user->password;
	   if($username == $uname && $password == $upass):
	    $tname = $_SESSION['tname'];
	    $tpass = $_SESSION['tpass'];
	   
	    echo "welcome $tname to your controll panel<a href='profile.php'>go to your profile</a>";  
	   else:
		   die('login failed');
	   endif;
		 endforeach;
	 }
	
    } }    
	 ?>	
  </div>
	
	  </div>
the result in profile.php : welcome to your controll panel go to your profile
the problem is the variables $tname and $tpass do not stock any session in the login
help me please
  • 0

#2 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 13 April 2012 - 01:48 AM

you didn't assign a value into the


$_SESSION['tname'];

and

$tpass = $_SESSION['tpass'];

try to put this code after the

if($username == $uname && $password == $upass):



insert this code..

$_SESSION['tname'] = $uname;
$_SESSION['tpass'] = $upass;

and please don't double post :)

Happy Coding
  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#3 promehdioh

promehdioh

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 13 April 2012 - 03:52 AM

thank you
did not pay attention to this
  • 0

#4 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 13 April 2012 - 04:13 AM

thank you
did not pay attention to this


you're always welcome :) don't hesitate to post or ask questions if you encounter some problems
this forum has a lot of expert to answer your question and help you in your projects :)
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#5 promehdioh

promehdioh

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 13 April 2012 - 09:19 AM

you're always welcome :) don't hesitate to post or ask questions if you encounter some problems
this forum has a lot of expert to answer your question and help you in your projects :)

thank you
  • 0





Also tagged with one or more of these keywords: session

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download