General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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 February 11th, 2003, 10:13 AM
neos neos is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: scotland
Posts: 6 neos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to neos
Post Pesristent or non persistent sessions?

I building an online dating agency and although i created my own library and session management, I implemented the site using non persistent session management.
thus, sessions are not saved anywhere, neother i use cookies but due to flexibility i can turn into persistent session management by storing everything in a table in MYSQL.

Do you think this appoach is good or do you think that by using server memory that at some point that there will be x amount of users on the server that we might have overload or no more memory to serve the operations of the site?

Reply With Quote
  #2  
Old February 11th, 2003, 12:50 PM
ramz ramz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Juiz de Fora - MG- Brazil
Posts: 93 ramz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to ramz Send a message via MSN to ramz
Hi Neos!
Hum... you idea seens to be very nice, but you'll have the problem that you've reported (server space plus memory), but how are you going to know which session belongs to each user, without using a cookie?
You'll keep a record in a database table, but how does it going to recognize the user?
__________________
Regards,
Ramiro Varandas Jr.

Reply With Quote
  #3  
Old February 13th, 2003, 06:56 AM
neos neos is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: scotland
Posts: 6 neos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to neos
sessions

hi there,

when i say no cookies i dont mean the cookie made by PHP during runtime, but cookies that we sent to the client during his session. thus i'm based on the session cookie that is created on the sessions folder of php.

i tried to incorporate cookies to the client but it did not work although all my configuration is correct. i think that i sent something to the browser before headers are sent .

so do you think that i should go with persistence rather than leave it with the sessions alone? that means that every page will be dependednt on the select statements to the sessions table to verify every user. would that not compromise the speed of every page?

Reply With Quote
  #4  
Old February 13th, 2003, 07:06 AM
ramz ramz is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Juiz de Fora - MG- Brazil
Posts: 93 ramz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to ramz Send a message via MSN to ramz
I don't know... You try...
You can try measuring time and speed in both methods and see which is better. Although, if you feel more comfortable work with these codes and variables, go foward. Web programming is not only speed and execution time, but the easier way for you to work on it.

Reply With Quote
  #5  
Old February 13th, 2003, 09:33 AM
neos neos is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: scotland
Posts: 6 neos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to neos
Post sessions

yes you are right ramz, test and see,

but hte problem is that i havent done before an applicaiton to incorporate maybe 500 users at the same time so i dont know which is best.
i use a function to set tokens once a login is suceeded. there there 5 session variables created. 5 session variables times 500 users would be a server load?

here is the code that i use to set variables once a login has succeeded :

PHP Code:
//some are objects that manipulate the database objects
//from objects.inc
include('objects.inc');
$loginsuccess=0;
$success false;
unset(
$success);

//functino to check if user is logged in
function user_isloggedin() {
  
// This function will only work with superglobal arrays, because
  // I'm not passing in any values or declaring globals
  
global $supersecret_hash_padding$success;

  
// Have we already run the hash checks?
  // If so, return the pre-set var
  
if (isSet($success)) {
    return 
$success;
  }
  if (isset(
$_SESSION['valid_user'])) {
  return 
true;
   } else {
     return 
false;
   }


}


function 
user_login($formname,$formpass) {

  global 
$psl_hash$loginsuccess;

  
// This function will only work with superglobal arrays, because
  // I'm not passing in any values or declaring globals
  
if (!$formname || !$formpass) {
    
$feedback 'ERROR - Missing username or password';
    return 
$feedback;
    exit;
  } else {
            
$formname strtolower($formname);
             
// Don't need to trim because extra spaces should fail for this
             // Don't need to addslashes because single quotes aren't allowed
            
$formpass strtolower($formpass);
  
//create new object
         
$login = new Account;
         
$login->account();
         
//get account details based on username
         
$login->get("username",$formname);

         
//if the suername is not found set flag loginsuccess to 0
         
if(($login->username=="")||($login->username==NULL)||(!$login->username)){ $loginsuccess0;}

         
$handle $login->username;
         
$pass $login->userpass;

         
//scrable the result with hash variable( unicque ticket)
         
$result $handle.$pass.$psl_hash;
         
//produce the same digest variable from form variables
         
$forms $formname.$formpass.$psl_hash;
         
//compare results
         
if ($result == $forms) {
               if(
$login->activated=="Y"){
                
//set the flag
                  
$loginsuccess 1;
                  
user_set_tokens($formname,$login->priv_id,$login->member_id,$login->ID);
                  return 
$loginsuccess;

                }else{
                
$loginsuccess 0;
                
$feedback 'Your account has not been activated..!<br>';
                return 
$feedback;
                exit;
                }


           }else {
                
$loginsuccess 0;
                
$feedback 'Invalid login details!.Please go back and try again<br>';
                return 
$feedback;
                exit;
              }

              
//return $loginsuccess;
  
}
}
//end of function user_login()

//function to call when user logs out
// destroy session
function user_logout() {
 
/* setcookie('user_name', '', (time()+2592000), '/', '', 0);
  setcookie('id_hash', '', (time()+2592000), '/', '', 0);*/
  // Unset all of the session variables.
session_unset();
// Finally, destroy the session.
session_destroy();
}

//function: to set the session variables if login is correct
//takes in as parameters username, privilidge id and memebrship id
function user_set_tokens($user_name_in,$p,$m,$id) {
  global 
$supersecret_hash_padding,$HTTP_SESSION_VARS;
  if (!
$user_name_in) {
    
$feedback =  'ERROR - No username';
    return 
false;
  }
  
$user_name strtolower($user_name_in);
  
$id_hash md5($user_name.$supersecret_hash_padding);

  
$last time();
   
/*
  $cookie_id = md5(uniqid(rand()));
  setcookie('PHPSESSID',$cookie_id,(time()+2592000),   '/', '', 0);
*/
    /* $id_hash = md5($user_name_in.$supersecret_hash_padding);
      send_htCookie("user_name",$user_name_in,(time()+2592000), '/','',1);
      send_htCookie("id_hash",$id_hash,(time()+2592000), '/','',1);*/

  /*setcookie('user_name', $user_name, (time()+2592000), '/', '', 0);
  setcookie('id_hash', $id_hash, (time()+2592000), '/', '', 0);*/
  //setcookie('pid', $p, (time()+2592000), '/', '', 0);
  //setcookie('mid', $m, (time()+2592000), '/', '', 0);

  //make a unique ticket to carry on session
  
$id_hash md5($user_name_in.$supersecret_hash_padding);


  
$_SESSION['id_hash']=$id_hash;
  
$_SESSION['valid_user']=$user_name_in;
  
$_SESSION['lasttime']=$last;
  
$_SESSION['pid']=$p;
  
$_SESSION['mid']=$m;
  
$_SESSION['aid']=$id;


}

/******************************
ysage:
send_htCookie(string varname (required),string varval,int expire,
string path, string domain, bool secure);
******************************/
function send_htCookie() {
 
$vars=array('varname','varval','expire''path','domain','secure');

 for (
$i=0;$i<func_num_args();$i++) {
    ${
$vars[$i]}=func_get_arg($i);
 }

 if (!
$varname) { return false; }

 
$COOKIE "Set-Cookie: $varname=$varval";
 if (isset(
$expire) && ($expire 0)) {
    
$COOKIE .= "; EXPIRES=".
    
gmdate("D, d M Y H:i:s",$expire) .
    
" GMT";}
 if (isset(
$domain)) { $COOKIE .= "; DOMAIN=$domain"; }
 if (isset(
$path))   { $COOKIE .= "; PATH=$path"; }
 if (isset(
$secure) && $secure>0) { $COOKIE .= "; SECURE"; }

 
header($COOKIE,false);
return 
true;


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Pesristent or non persistent sessions?


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway