Current location: Hot Scripts Forums » Programming Languages » PHP » how to get my sessions script work with cookies


how to get my sessions script work with cookies

Reply
  #1 (permalink)  
Old 06-23-03, 10:46 AM
JM007 JM007 is offline
New Member
 
Join Date: Jun 2003
Location: Belgium
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
how to get my sessions script work with cookies

I'm trying to convert my session login system to a cookie login system but it doesn't seem to be working,every time I login I get a white page.What am I doing rang?
PHP Code:

<?php


if (!empty($_POST)){
mysql_connect("localhost","username","pas");
mysql_select_db("db") or die("connectie mislukt");
    
$query "SELECT * FROM users 
                WHERE username='" 
$_POST["username"] ."' 
                AND pass='"
$_POST["pass"] . "'"
    
$result mysql_query($query) or die("FOUT : " mysql_error()); 
    if (
mysql_num_rows($result) > 0){
        
// username found
                
$username $_POST["username"];
                
$pass $_POST["pass"]; 
                
     
setcookie("username,$username,time()+1209600"); 
     
setcookie("pass,$pass,time()+1209600"); 
            
        
// send to page
        
header("test.php"); 
      
    }else{
            
// incorrect login 
   
header("login.php");     
        }
}else{
    
// page was not called correct
    
header("Location: [url]http://www.stw.be[/url]"); 
}
?>

I'm adding this to every page that I want to secure ;

<?php 
if (!isset($_COOKIE["username"])){
    
$text "<h2>You're not logged!.</h2>";
    echo(
$text);
}else
{

echo(
"<h2>Welkom op deze beveiligde pagina</h2>");

}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-24-03, 09:06 AM
Chris Boulton Chris Boulton is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 208
Thanks: 0
Thanked 0 Times in 0 Posts
Change

PHP Code:

    setcookie("username,$username,time()+1209600"); 

     
setcookie("pass,$pass,time()+1209600"); 
to

PHP Code:

    setcookie("username",$username,time()+1209600); 

     
setcookie("pass",$pass,time()+1209600); 
Now it should work
__________________
Chris Boulton
SurfiOnline!
MyBulletinBoard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a good review management script griz_fan Script Requests 10 07-29-07 06:08 AM
Download files from another server using script! benweston Script Requests 5 01-17-06 10:29 AM
PHP & sessions, why won't it work? TinnyFusion PHP 1 10-04-03 02:51 PM
Talkback script..help pls BC_ PHP 0 06-22-03 07:44 PM
Need help with a script boardpix PHP 7 06-09-03 12:37 AM


All times are GMT -5. The time now is 12:29 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.