PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 6th, 2007, 12:59 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Sessions clearing

i have been using sessions to get information from the db. i have this probelm that after the first time the page loads, it empties all data from the sessions. i store session data in my mysql db, but have had no problems like this before.
can someone please help me?

Reply With Quote
  #2  
Old March 6th, 2007, 01:44 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Erm? A little low on info. Have you disabled cookies perhaps? Firefox's Webdeveloper add-on has that option.

Show us some code if you want us to help.
__________________
One World... Humanetainit | Program secure

Reply With Quote
  #3  
Old March 6th, 2007, 04:07 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
Erm? A little low on info. Have you disabled cookies perhaps? Firefox's Webdeveloper add-on has that option.

Show us some code if you want us to help.

i havent disabled cookies because the same session works fine in other pages. untill i enter this page where the session data is instantly emptied, every time.using firefox's web developer add-on, i have determined that the cookies do not change, it is just the session data is emptied.

Last edited by alicats12345 : March 6th, 2007 at 04:10 PM. Reason: extra thoughts

Reply With Quote
  #4  
Old March 6th, 2007, 06:49 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 330 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 5 h 3 sec
Reputation Power: 15
can we see some code?

Reply With Quote
  #5  
Old March 7th, 2007, 01:53 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Viper_SB
can we see some code?

here is the code that i belive has the fault in:
PHP Code:
if (!isset($_SESSION)) {
  
session_start($_SESSION);
}

//deny access if not logged in
if(checkAuth($_SESSION['user'],'*') == 'fail')
{
  
//not allowed
  
header("Location: login.php?access_url=".get_cur_pos($_SERVER['PHP_SELF'])."&error=insuff");
}
//check for submitted form
  //check to see if the form has already been submitted, or whether it is just aa failure in the script
if($_POST['userid'] != NULL && $_POST['cs'] != NULL)
  {
    
//the form has been submitted, handle this now.
    //check the validation images
    
$cs GetSQLValueString($_POST['cs'],'text');
    
$confirm_val $_POST['visual_code'];
    
//remove the '' from confirm_val
    
$res mysql_query ("SELECT * FROM eezybb_visual_confirm WHERE confirm_ses = $cs LIMIT 1",$forum) or dead("MySQL",mysql_error());
    
$row mysql_fetch_array ($res); 
    
    if (
$row['confirm_val'] == $confirm_val
    {
        
//correct validation image code
        
$db->freeresult($res); 
        
    }
    
  }
  else
  {
    
//show the profile form
    //setup the visual confirmation code ids
    
function random_str ($len)
    {
     
$ch "ABCDEF1234567890";
     
$l strlen ($ch) - 1;
     
$str "";
     for (
$i=0$i $len$i++)
     {
         
$x rand (0$l);
         
$str .= $ch[$x];
     }
     return 
strtolower ($str);
    }
    
$ses random_str (16);

    
//get the users current values
    
$sql "SELECT * FROM eezybb_users WHERE username = ".GetSQLValueString($_SESSION['user']['username'],'text')."";
    
$user mysql_query($sql,$forum) or dead("MySQL",mysql_error());
    
$row_user = array();
    while(
$row mysql_fetch_assoc($user)){
      
$row_user[] = $row;
    } 

cont...

Reply With Quote
  #6  
Old March 7th, 2007, 02:05 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Try

session_start();

instead of

if (!isset($_SESSION)) {
session_start($_SESSION);
}

I don't see what's the sense in doing session_start($_SESSION);

Reply With Quote
  #7  
Old March 7th, 2007, 03:02 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
i have had no luck with changing the session_start();. does anybody else have anyideas of how to sort out this. view this at: http://eezybb.freehostia.com login using
username: test
password: testing0134==
when logged in click on the profile button at the top and refresh the page twice.

Reply With Quote
  #8  
Old March 8th, 2007, 02:07 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
The error must be in
PHP Code:
if(checkAuth($_SESSION['user'],'*') == 'fail'

Using PEAR? Check the PEAR manual. Maybe:
PHP Code:
if(checkAuth($_SESSION['user'],'*') == FALSE

Last edited by Humanetainit : March 8th, 2007 at 02:11 PM.

Reply With Quote
  #9  
Old March 8th, 2007, 02:45 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
The error must be in
PHP Code:
if(checkAuth($_SESSION['user'],'*') == 'fail'

Using PEAR? Check the PEAR manual. Maybe:
PHP Code:
if(checkAuth($_SESSION['user'],'*') == FALSE

the checkAuth funtion is one that i have written myself
code:
PHP Code:
function checkAuth($user_session,$allowed_lvlids)
 {
   
//assign session vars
   
$username $user_session['username'];
   
$lvl $user_session['user_lvl'];
   
$uid $user_session['user_id']; 
   
//start with not authorized
   
$auth 'fail';
   
//chck if not logged in
   
if($username == NULL || $uid == NULL || $lvl == NULL)
   {
     
//user not logged in
     
$auth 'fail';
   }
   else 
   {
     
//user is logged in
     
$allowed_lvls explode(",",$allowed_lvlids);
     if(
in_array($lvl,$allowed_lvls) || $allowed_lvlids == "*")
     {
       
$auth 'auth';
     }
   }
   return 
$auth;
 } 

Reply With Quote
  #10  
Old March 9th, 2007, 01:47 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
If you try to echo out the session, you might be able to figure out where it goes amiss.
PHP Code:
foreach ($_SESSION['user'] as $key => $var) {
echo 
$key ': ' $var '<br />';


Reply With Quote
  #11  
Old March 9th, 2007, 01:51 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Or try:
PHP Code:
if($username === NULL || $uid === NULL || $lvl === NULL

Reply With Quote
  #12  
Old March 9th, 2007, 11:07 AM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
Or try:
PHP Code:
if($username === NULL || $uid === NULL || $lvl === NULL

looking at the header(which changes depending on user loggin status) that the page has the session for the mysql query, however printing to page is the last thing and by which time it has lost contact if the session data. i will try using your function to see where in the page it dissappearts and post on this websirte the results.

Reply With Quote
  #13  
Old March 9th, 2007, 11:15 AM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
the session data is clearing when i run the mysql query:
PHP Code:
 $sql "SELECT * FROM eezybb_users WHERE id = ".GetSQLValueString($_SESSION['user']['user_id'],'int')." AND username = ".GetSQLValueString($_SESSION['user']['username'],'text')."";
  
$user mysql_query($sql,$forum) or dead("MySQL",'Unable to get the user data for populating the form grid');
  
$row_user = array();
  while(
$row mysql_fetch_assoc($user))
  {
    
$row_user[] = $row;
  } 

the GetSQLValueString is :
PHP Code:
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType)
  {
    case 
"text":
    
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
    break;
    case 
"long":
    case 
"int":
    
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case 
"double":
    
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
    break;
    case 
"date":
    
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
    break;
    case 
"defined":
    
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
    break;
  }
$theValue strip_tags($theValue,'<br/><hr /><hr>');
$theValue htmlspecialchars($theValue);
return 
$theValue;


what is happeining to cause this.

Reply With Quote
  #14  
Old March 9th, 2007, 12:35 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
I don't see the problem. Does it occur when you remove the block of code?

Reply With Quote
  #15  
Old March 9th, 2007, 01:22 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
I don't see the problem. Does it occur when you remove the block of code?

i fi remove that query the sessions work, but i need that query!

Reply With Quote
  #16  
Old March 9th, 2007, 02:07 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
The script works ok over here. Is the $row_user array used further on in the script?

Reply With Quote
  #17  
Old March 9th, 2007, 02:25 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
The script works ok over here. Is the $row_user array used further on in the script?

yes it is used to fill in a form. which is the whole point of the page!

Reply With Quote
  #18  
Old March 9th, 2007, 02:56 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Okay, but is it possible the fault lies there?

Reply With Quote
  #19  
Old March 9th, 2007, 03:13 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Mars
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 36 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Humanetainit
Okay, but is it possible the fault lies there?
as far as i am aware there is no fault further on in the page. the problem was the use of the $row_user and $user. i dont see why because i have nothing assigned to those, but by changing them i have the page working.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Sessions clearing


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap