PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 23rd, 2005, 12:57 PM
toplisek toplisek is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 140 toplisek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 22 sec
Reputation Power: 3
How to do that user will not be automatic logged in? Need help

I have cookie and it is set with code:
php Code:
Original - php Code
  1. setcookie('cookname', $_POST['usernamelogin']);   


user is automatic logged in with code on each page:
php Code:
Original - php Code
  1.  
  2.    if(isset($_COOKIE['cookname']) /*&& isset($_COOKIE['cookpass'])*/)
  3.           {
  4.             $user = $_COOKIE['cookname'];
  5.           //  $crypt_user = md5 ($_COOKIE['cookname'] );
  6.             $SESSID  = md5( time() );
  7.            /* $password = $_COOKIE['cookpass'];   */
  8.  
  9.  
  10.                $sql = "SELECT * FROM membership WHERE usernamemem = '$user'";
  11.                $sql = mysql_query($sql);
  12.                $result = mysql_fetch_assoc($sql);
  13.  
  14.                if(   $user == $result['usernamemem'] /*&&
  15.                           $password == $result['password']*/    )
  16.                   {
  17.                         //  $_SESSION['logged'] = TRUE;
  18.                         // $validation=TRUE;
  19.                          $SESSID  = md5( time() );
  20.  
  21.  
  22.                           $query1 = " DELETE FROM users_session
  23.                             WHERE SESSusername = '{$user}'";
  24.                              mysql_query ($query1,$link)
  25.                              or die ("Delete error:".mysql_error());
  26.  
  27.                            $query2 = "INSERT INTO users_session
  28.                            SET
  29.                               `SESSID` = '{$SESSID}',
  30.                               `SESSusername` = '{$user}',
  31.                               `SESSIP` = '{$_SERVER['REMOTE_ADDR']}',
  32.                               `SESStype` = 'logged',
  33.                             `TimeOut` = UNIX_TIMESTAMP()" ;
  34.                                 $_SESSION['logged'] = TRUE;
  35.                                 $_SESSION['SESSID']= $SESSID;
  36.                                 $_SESSION['SESSusername'] = $user;
  37.                                 $_SESSION['SESSIP']= $_SERVER['REMOTE_ADDR'];
  38.                                 $_SESSION['SESStype']= 'logged';
  39.                                 $_SESSION['TimeOut']= 'UNIX_TIMESTAMP()';
  40.                            mysql_query ($query2,$link)
  41.                            or die ("Insert error:".mysql_error());
  42.                                   //print 'logged in!!';
  43.                      }    //passwords dont mach
  44.            }
  45.  


How to do that if user decides logout, cookie will be with value empty? I have on logout page:

php Code:
Original - php Code
  1. setcookie('cookname', '', time()-3600);
  2.  
  3. $_COOKIE['cookname']=FALSE;


But this logout does not reset cookie. What is problem? Please help..he will be again logged in

Reply With Quote
  #2  
Old November 25th, 2005, 12:24 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,753 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 8 h 15 m 54 sec
Reputation Power: 7
RE: How to do that user will not be automatic logged in? Need help

I beleive you need to unset the cookie, not make it's value false and destroy the seesion.

Reply With Quote
  #3  
Old November 25th, 2005, 09:35 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: How to do that user will not be automatic logged in? Need help

I have noticed that to unset the cookie, I have to give under
session_start();
setcookie('cookname', '', time()-3600);


Now it works, but I would like to include file in logout page. Do you know how is correct all code to
reset all session and cookies in such file?




Reply With Quote
  #4  
Old November 27th, 2005, 04:22 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,753 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 8 h 15 m 54 sec
Reputation Power: 7
RE: How to do that user will not be automatic logged in? Need help

I would also look in the manual under unset.
php Code:
Original - php Code
  1.  
  2. unset($_COOKIE['cookname']);

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > How to do that user will not be automatic logged in? Need help


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek