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



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

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 July 21st, 2002, 07:38 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 588 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Article Discussion: Developing Custom PHP Sessions

Developing Custom PHP Sessions If you have any questions or comments about this article then please post them here.

You can read the article here .

Reply With Quote
  #2  
Old August 18th, 2002, 09:34 AM
Frederic Boije Frederic Boije is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problems with

I have problem running this script. What am I doing wrong?

I get the following error msg:

Warning: Cannot add header information - headers already sent by (output started at /opt/www/login.php:13) in /opt/www/sess.php on line 55

Warning: Cannot add header information - headers already sent by (output started at /opt/www/login.php:13) in /opt/www/login.php on line 20

// Frederic Boije

Reply With Quote
  #3  
Old August 18th, 2002, 07:29 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
looks like your sending out the headers early, make sure you aint outputting anything or have whitespace

Reply With Quote
  #4  
Old August 21st, 2002, 02:14 PM
ozric ozric is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Detroit, MI
Posts: 3 ozric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well if you copy and paste the scripts from the article, I get the same results.

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data/sess.php:145) in /usr/local/www/data/sess.php on line 53

Warning: Cannot add header information - headers already sent by (output started at /usr/local/www/data/sess.php:145) in /usr/local/www/data/login1.php on line 13

Line 53 in the sess.php include is:
// set the cookie that will store the session key
setcookie("sess_key",$this->key,time()+3600);
}

Shouldn't the examples from the article work first before I start modifiying & adapting them?

Jim

Reply With Quote
  #5  
Old August 21st, 2002, 03:06 PM
ozric ozric is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Detroit, MI
Posts: 3 ozric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
With the given database schema from the article;

PHP Code:
 create table sessions 
id int(10NOT NULL AUTO_INCREMENT
sess_key char(6NOT NULL
val varchar(250NOT NULL
ip varchar(35NOT NULL
access int(25NOT NULL
PRIMARY KEY(id
); 


How are we suppose to INSERT using the following query from the example?

$insert = mysql_query("INSERT INTO sessions (sess_key, val, ip, sec_expire, stamp_expire, access) VALUES ('" . $this->key. "', '" . addslashes($val) . "' , '" . $_SERVER["REMOTE_ADDR"] . "' , " . $this->timeout . "," . (time() + $this->timeout) . "," . time() .");");

The above query assumes you have these database fields:
sess_key,
val,
ip,
sec_expire,
stamp_expire,
access

Jim

Reply With Quote
  #6  
Old August 21st, 2002, 07:24 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
the article does work! dont you listen to me!

Quote:
looks like your sending out the headers early, make sure you aint outputting anything or have whitespace


if you copy paste the code it, make sure it doesnt have any white space.

In other words, make sure the VERY first charcters of the file are

<?

there shouldnt be any spaces in front of it

if that still doesnt work, make sure you arnt echoing or printing our anything!

Reply With Quote
  #7  
Old August 22nd, 2002, 12:33 PM
ozric ozric is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Detroit, MI
Posts: 3 ozric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply!

I took care of the header problem before your repsonse. I set the output buffer to "1" in my php.ini file..... I will go back and check for white space.

How about the database descrepency? Am I overlooking something here? I can't get the INSERT statement to work and I think it is because of the database structure difference...

Thanks!

Jim

Reply With Quote
  #8  
Old August 22nd, 2002, 02:19 PM
loboe loboe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 1 loboe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post

I don't doubt that in fact it works, but I have had many problems with this tutorial.

The last one:

Notice: Undefined variable: login in ...\login.php on line 5

I believe that this variable is not defined, neither $logout (in Welcome.php)

Is somebody able to unveil something on the variable $PHP_SELF ?? In the manual only a reference appears about $_SERVER [' PHP_SELF']...

Still is pending the question pointed out by Ozric on the discrepancies in the database (is it maybe a characteristic of MySQL?)

In my opinion the tutorial lack of more additional information and certainly it is not for beginners.

Reply With Quote
  #9  
Old August 22nd, 2002, 04:04 PM
Frederic Boije Frederic Boije is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Malmö - Sweden
Posts: 19 Frederic Boije User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have the solution

The problem with this example are mainly two things:

1. You need to fix the table fields to match the insert statment. The mySQL table is missing some of the fields in the example. Make sure the fields sec_expire(int 25), access(
timestamp) and stamp_expire(timestamp) is in there.

2. The script automaticly updating both timestamp fields. Why? Because mySQL automaticly updates the first datetime field in a table So if you put access after stamp_expire you are having the same problem as I had. Shift the order - problem fixed.

The good thing about this example is that I really learned somting out of debugging it! Frankly - I would never had learned so much without having to fix the problem!!

It is a very good object-oriented code, and if somebody is interested, I would gladly give the code with my modifications or try to help you guys.

Reply With Quote
  #10  
Old August 22nd, 2002, 06:06 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,240 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Quote:
Originally posted by loboe
I don't doubt that in fact it works, but I have had many problems with this tutorial.

The last one:

Notice: Undefined variable: login in ...\login.php on line 5

I believe that this variable is not defined, neither $logout (in Welcome.php)

Is somebody able to unveil something on the variable $PHP_SELF ?? In the manual only a reference appears about $_SERVER [' PHP_SELF']...


Loboe,

Check to make sure your register_globals setting is set to "off" in your php.ini file... The new way of accessing variables in PHP is by using the SUPERGLOBALS array system:

$_POST['<variableName>']
$_GET['<variableName>']


For your example, you'll need to modify the code so that it uses $_POST['login'] and $_POST['logout'] rather than just $login and $logout
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #11  
Old August 22nd, 2002, 06:52 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
that article was writen when 4.0 (i think) was out. since then with 4.1 and 4.2 you access the vars in a different way, as Frankie suggested. you need to go back, and change all the vars, into super globals

Reply With Quote
  #12  
Old November 25th, 2002, 10:21 AM
Santo Santo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Belgium
Posts: 1 Santo 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 Santo
if i'm not mistaken, this article is ment as a means to guide you trough your own session handling, not to completely build it from scratch for you!

If you want to copy/paste some code and hope for it to work, I suggest you go elsewhere. The article tries to give you an insight on how to handle your own session management, and after reading it i must admit it is one of the clearest and best articles on session management so far.

my 2 cents


Reply With Quote
  #13  
Old December 6th, 2002, 04:10 PM
jhoover jhoover is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 1 jhoover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This does work!!

I have been looking all over the web for an article on this subject and this one is excellent.

The sample code did have a few syntax issues: the included .sql file had minor issues discussed in previous postings, I did have to tweak the variables in the sample files because I'm not using global variables (also discussed) and I did notice the call to the destroy() function within the expire() function listed it as "destory", which again no big deal. Pretty minor debugging overall.

I think this is well written code and is something that you can actually run with. So many times examples prove concepts but don't solve real world issues. This one does. Thanks!!!

Jason

Reply With Quote
  #14  
Old January 15th, 2003, 09:51 AM
gipper13 gipper13 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 1 gipper13 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Can this be used for a shopping cart? I keep trying it and can't get the thing to work. I don't need or want someone to have to login just to see the site. I would like to create a session and when they add stuff to a cart it goes into this session and eventually into a database when they submit the order.

Reply With Quote
  #15  
Old January 16th, 2003, 11:29 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
The article does work, I took the source and put it into effect to see what all was doing what.. Now I'm using the inspiration I got from the article to make my own

I didn't know squat about sessions before.. and I still don't know as much as I could, but I'm getting there

But it does work without a problem... and as Ben and Frankie said, you may need to change the way that your variables are being handled..

Reply With Quote
  #16  
Old February 7th, 2003, 10:29 AM
pakcik_kantin pakcik_kantin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Kantin
Posts: 18 pakcik_kantin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What happen if the user simply close the browserWhat happen if the user simply close the browser

Reply With Quote
  #17  
Old February 28th, 2003, 04:50 PM
treycarroll treycarroll is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: TEXAS
Posts: 3 treycarroll User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post My rendition of this code

I found bugs and inconsistencies in this code when I started to work with it. (table schema != sql queries, location missing trailing colon, timestamp logic needlessly complex). But I am VERY grateful to Brian for creating this; it served as an excellent starting point for learning about custom sessions.

I tweaked this code for my purposes and it works well. I have added a feature to detect login sharing violations.


Create this table:

CREATE TABLE sessions (
sess_key char(6) NOT NULL,
val varchar(30) NOT NULL,
ip varchar(32) NOT NULL,
unix_time_expire int(20),
PRIMARY KEY(sess_key)
);

sess.php:
PHP Code:
<?php
$host
=;//fill in with appropriate values
$user=;
$pass=;

$dbc mysql_connect($host,$user,$pass) or die("Cannot establish a connection to the database.");
mysql_select_db($db,$dbc);
    
class 
session 
    
{
    var 
$key "";
    var 
$timeout;

    
// start() will initialize the session by generating the session key or ID
    
function start($timeout "") {
        
    
// create an array with all the letters of the alphabet
    
$letters range("a","z");
    

    
// generate our session's key formatted such as #a#aa#
    
for($i 0$i 6$i++) 
        {
        if((
$i == 0) || ($i == 2) || ($i == 5))
            
$key .= rand(0,9);
        if((
$i == 1) || ($i == 3) || ($i == 4))
            
$key .= $letters[rand(0,25)];
        }

    
// store the session's key in a method of the class
    
$this->key $key;
        
    
// perform a conditional to test if the user defined the timeout and if not store the default value.
    
if($timeout == "")
        
$this->timeout 300// five minutes
    
else
        
$this->timeout $timeout;
    return 
0;
}

// this function will register a value to session. (only one value, see replace() to update the value)
function register($val
    {
    
// if key is not generated run start()
    
if($this->key == "")
        
$this->start();

    
// check for account sharing violators
    
$strSQL"SELECT ip FROM sessions WHERE val='$val' AND ip <> '".$_SERVER['REMOTE_ADDR']."' AND unix_time_expire >".time();
    
$query mysql_query($strSQL);
    
$fetch mysql_fetch_array($query);
    
$db_violator_ip $fetch["ip"];


    if(@
mysql_num_rows($query) != 0//Somebody from a different ip is logged in using this user id: sharing violation
        
{
         
//disable their account
         // Assumes you have created a table called member that contains a field named active
         // which is tested along with user_id and password at login
        
$query mysql_query("UPDATE member SET active='N' WHERE user_id='$val'");
         
         
//email the administrator
             
$to  "admin<admin@somesite.com>" "," // note the comma
                                            
            /* subject */
            
$subject "Membership Sharing Violation";
                                        
            
/* message */
            
$message .= "User Name:$val\n";
            
$message.= "Time of violation:".time()."\n";
            
$message.= "IP #1: ".$_SERVER['REMOTE_ADDR']."\n";
            
$message.= "IP #2: $db_violator_ip \n";
            
$message.= "Member has been notified of account suspension and advised\n";
            
$message.= "that they will be contacted by site admin.\n";
                                                                                
            
/* additional headers */
            
$headers .= "From: Admin System <auto@somesite.com>\r\n";
            
$headers .= "Reply-To: Do Not Reply to This Message\r\n";
            
$headers .= "X-Mailer: PHP/".phpversion();
                                            
            
/* and now mail it */
            
mail($to$subject$message$headers);
                                            
         
//route them back to the login page
         
header("Location: login.php?sharing_violation=true");
         exit;                  
        }        
    else
        {
        
$insert mysql_query("INSERT INTO sessions (sess_key, val, ip, unix_time_expire) VALUES ('" $this->key"', '" addslashes($val) . "' , '" $_SERVER["REMOTE_ADDR"] . "' , " .(time() + $this->timeout) . ");");
 
         
// set the cookie that will store the session key
        
setcookie("sess_key",$this->key,time()+3600);
        }
}

function 
read() {
        
    
// set $sess_val global - the variable of the session value.
    
global $sess_val;
        
    
// if the cookie doesn't exisit send them back to the login screen.
    
if(!$_COOKIE["sess_key"]) 
        {
        
header("Location: login.php");
        exit;
        }

    
// fetch the session key from the cookie.
    
$this->key $_COOKIE["sess_key"];

    
// fetch the session value
    
$query mysql_query("SELECT * FROM sessions WHERE sess_key = '" $this->key "'") or die("query failed - line 55");

    if(
mysql_num_rows($query) == 0
        {
        
header("Location: login.php");
        exit;
        }

    
$fetch mysql_fetch_array($query);

    
// store the session value to $sess_val
    
$sess_val stripslashes($fetch["val"]);
    
    
// store the session ip to $sess_ip
    
$sess_ip $fetch["ip"];
        
    
// test if session has reached the expiration point
    
$this->expire();

}

// this function will test if the user has been inactive for the defined timeout
function expire() {
        
    
// fetch the last access and expirations from the database
    
$strSQL"SELECT unix_time_expire FROM sessions WHERE sess_key = '" $this->key "'";    

    
$query mysql_query($strSQL) or die("query failed - line 95");
    
$fetch mysql_fetch_array($query);

    
$unix_time_expire $fetch["unix_time_expire"];

    
// test if session is expired based on defined timeout
    
if(time() > $unix_time_expire)
        {
        
$this->destroy();                               }
}

// this function will update the session value
function replace($val) {

    
// fetch the user key from cookie
    
$this->key $_COOKIE["sess_key"];

    
// update the database with the new value
    
$query mysql_query("UPDATE sessions SET val = '" $val "' WHERE sess_key = '" $this->key) or die("query failed - line 77");
}

// this function will kill the session
function destroy($key "") {

    
// fetch the user key from cookie
    
$this->key $_COOKIE["sess_key"];

    
// delete session from database
    
$query mysql_query("DELETE FROM sessions WHERE sess_key = '" $this->key "'") or die("query failed - line 86");

    
// remove cookie from the user's computer
    
$delete setcookie("sess_key" $this->keytime()-3600);    

    if(
$query && $delete) {
        
header("Location: login.php?timeout=true");
        exit;
    }

}

}
?>


The login form has been sightly changed to make it nicer. It still needs real code added to compare user_id, password to the db and check to see if active='Y'. (Right now it just accepts all logins.)

Here is the new login.php:

PHP Code:
<?php

require_once("sess.php");

if(
$_POST['login']) 
    {
    
$sess = new session;

    
$sess->start(30); //30 seconds is a nice, short time to initially test this.  Brian's code was set to 300 seconds

    
$sess->register($_POST['username']);

    
header("Location: next.php");
    }
    
echo 
"<html>\n";
echo 
"<head>\n";
echo 
"<title>login</title>\n";
echo 
"<style>.timeout_text{color:red;font-weight:bold}\n.violation_text{color:red;font-weight:bold}</style>\n";

echo 
"</head>\n";
echo 
"\n";
echo 
"<body>\n";

if (
$_GET['timeout'])
    {echo 
"<center><table width='30%' style='background:beige;border-style:solid;border-color:black;border-width:1px'><tr><td><span class='timeout_text'>Your Session has timed out.  Please log back in again now.</span></td></tr></table></center>";}

if (
$_GET['sharing_violation'])
    {echo 
"<center><table width='30%' style='background:beige;border-style:solid;border-color:black;border-width:1px'><tr><td><span class='violation_text'>You've been busted sharing your account information! Your account has been disabled.  You will be contacted by the administrator.</span></td></tr></table></center>";}

?>

<center>

<form method="post" action="login.php">
<table style="background:beige;border-style:solid;border-color:black;border-width:1px">
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="30"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="30"></td>
</tr>
<tr><td align="center" colspan="2"><input type="submit" name="login" value="Login"></td></tr>
</table>
</form>
</center>
</body>
</html>


Finally, the code for next.php

PHP Code:
<?php 
require_once("sess.php"); 

$sess = new session;
$sess->read();
?>

<html>
<head>
<title>Next</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<table>
<tr>
<th style="background:beige">This page is used to test the session timeout. After 30 seconds clicking this <a href="last.php">link</a> will route you back to the login page.</td>
</tr>
</table>

</center>
</body>
</html>

last.php (not included) is just some inane page with the same PHP code at the top as next.php - with a link back to next- so that you can waste time until the session times out.

In order to test the login sharing violation you'll need to have a friend login from a different ip with a username before you attempt to login using the same username. Right now of course, the account is not truly disabled- the appropriate message is just displayed.

Love or hate my code? Post a critique. I'm always learning and would appreciate the feedback!

Thanks,
Trey

PS I'm looking for a job.

Last edited by treycarroll : February 28th, 2003 at 05:53 PM.

Reply With Quote
  #18  
Old February 28th, 2003, 05:06 PM
treycarroll treycarroll is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: TEXAS
Posts: 3 treycarroll User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post taking out the trash

As pakcik_kantin points out, if the user just closes the browser the session is not deleted from the db. This happens if they type in a different url as well. To clean the trash out of the db. I wrote this little piece of perl to run on a crontab once a day:

#! usr/bin/perl

# THIS LITTLE SCRIPT REMOVES THE 'TRASH' FROM THE SESSIONS TABLE:
# SESSIONS THAT HAVE EXPIRED BUT WERE NEVER REMOVED ARE DELETED
# ONCE THE SCRIPT HAS RUN, ONLY ACTIVE SESSIONS WILL BE LEFT IN THE TABLE
# 'sessions'.

use DBI;
use strict;
my($dsn) = "DBI:mysql:<<Put your db name here>>:<<Put your host name>>"; #data source name
my($user_name) = ""; #put your db user_name here
my($password) = ""; #put your db pass here
my($dbh,$sth);
my($strSQL);

#connect to db
$dbh = DBI->connect($dsn,$user_name,$password, { RaiseError => 1 });

$strSQL = "DELETE FROM sessions WHERE unix_time_expire < UNIX_TIMESTAMP()";

$sth = $dbh->prepare($strSQL);

$sth->execute();

$sth->finish();
$dbh->disconnect();
exit(0);

Reply With Quote
  #19  
Old March 17th, 2003, 01:25 PM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
Thanks treycarroll !

It is really good revised code you have here. I am currently working a Members Area using SessionId but not Custom Session. The thing I don't like it very much is the the 32 chars attaching in the link. I think the codes you have fixed here is really great. Now I am trying to create a table that holds info of members and some checking against the db if correct info they can be logged in. But I don't know what to start first. If you have any ideas please help me. Anyway, thanks for your time.

Cheers,

Last edited by wareseeker : March 17th, 2003 at 02:15 PM.

Reply With Quote
  #20  
Old March 18th, 2003, 08:07 AM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
Please help? How come the cookie never sent to my browser of my computer at home but it worked at school? Any ideas would be appreciative.

Thanks all.

Reply With Quote
  #21  
Old March 19th, 2003, 09:01 AM
Mary Mary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 59 Mary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 17 sec
Reputation Power: 0
I have the same problem as Wareseeker had. All my codes uploaded into remote server(hosting service). When I tried to test the code by running my computer at home the cookie did not establish but it installed data into db.
And I tried on every computers at shool It worked perfectly but a small problem that when I logged out it did not redirect to the login.php instead of a blank white page.
Do you think that the browser did not create a cookie becuase I have Apache, PHP , and MySQL installed in my Win XP?
Does anyone or the Author of this article know the problem? Please help us. Greatly appreciate.

Regards,
Mary

Reply With Quote
  #22  
Old March 19th, 2003, 09:36 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 16
warseeker>> Please help? How come the cookie never sent to my browser of my computer at home but it worked at school? Any ideas would be appreciative.

Mary>> I have the same problem as Wareseeker had. All my codes uploaded into remote server(hosting service). When I tried to test the code by running my computer at home the cookie did not establish but it installed data into db.

---------------------------

If I get a chance today I will look at the code and break it down and change a couple things to alleviate the problems.

If Brian comes through here, I would like to know why he did not utilize the resources already available to him that have been built into PHP to create custom session handlers. Not only are they much, much more faster - but they are also more reliable and alleviate a few of the problems I have seen in this thread.
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #23  
Old March 19th, 2003, 09:48 AM
Mary Mary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 59 Mary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 17 sec
Reputation Power: 0
Thumbs up

Oh God! Thank you very much jpenn. Finally, my thread has been noticed. Hope to see a good thing coming...

Reply With Quote
  #24  
Old March 19th, 2003, 09:57 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 16
This article is an extremely weak method in tracking users as there are a number of holes in the code/architecture. No offense to anyone but I think someone needs to review these things before they are posted. Mary, wareseeker - sorry, but I can't provide any answers to your dillema as I am very finicky on things like this and I believe this article should not be posted because of the weak architecture used.

Reply With Quote
  #25  
Old March 21st, 2003, 02:47 PM
Mary Mary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 59 Mary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 17 sec
Reputation Power: 0
I am so sad to see this . I though this article will help me to create a Members Area with custom session. Now my hope is gone. Does anyone know any books or tuts that teach how to create a Members Area like vBulletin we have here please let me know. Greatly appreciative.

Reply With Quote
  #26  
Old March 21st, 2003, 06:44 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 16
To answer the call - I am working on an interface for this (custom session handlers). Through the web interface you can do your session configuration and then download the class/methods package - drop in your app use use. I should have the interface complete in the next 24 hours or so. I will send you a link to it when it is done....

Reply With Quote
  #27  
Old March 25th, 2003, 03:42 PM
Mary Mary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 59 Mary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 17 sec
Reputation Power: 0
Hello Joe!

It is really cool! I love it. The link that you mentioned is in your signature. Is it right?

I already downloaded it, but I don't know how create 3 files that I should have: the login.php, logout.php, and members.php. Joe, could you help me to create those files so I can have the first essential step to develop the next steps based on this step.

I am greatly appreciative for your help and your time.

Regards,
Mary

Reply With Quote
  #28  
Old March 26th, 2003, 10:14 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 16
Check the php articles section here on this site. Ben posted an article/tutorial (class) for user auth. This will get you going.

Reply With Quote
  #29  
Old March 26th, 2003, 10:44 PM
Mary Mary is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 59 Mary User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 17 sec
Reputation Power: 0
Unhappy

What's article Joe? I couldn't find it. Please help.

Reply With Quote
  #30  
Old March 27th, 2003, 09:02 AM
wareseeker wareseeker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 71 wareseeker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 7 sec
Reputation Power: 16
Unhappy

Hello Joe!

Could you please create some sample files how to use the object.session.php file. It would be easy for us to follow and learn from your code. Thanks.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: Developing Custom PHP Sessions


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