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:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old April 15th, 2002, 02:54 AM
wAr-AnGeL wAr-AnGeL is offline
Forum Security
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Behind You
Posts: 479 wAr-AnGeL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m
Reputation Power: 7
Send a message via ICQ to wAr-AnGeL Send a message via AIM to wAr-AnGeL
Question Using cookies with forms

I have a basic authentication script using PHP to verify username & password from a MySQL db. How could I make it so the users would not need to login everytime and a cookie could just save their info?
__________________




"Only Linux users see the end of crashes."
- Pl4t0

Reply With Quote
  #2  
Old April 15th, 2002, 04:32 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
ive never tried to program username remebers using cookies before, but im guessing it would go something like this

when the user is accepted by the submit form, if the password and username is checked and passed, a cookie is created with the usernames 'name' (hehe bad joke!) when the comeback to the login form again, in the header of the script check to see if theres a cookie, if so check the value of the cookie against the database, if correct, auto login!

anyways thats how i would do it, if you wanted to be more secure you could encrypt the password, and store that as a cookie as well

Reply With Quote
  #3  
Old April 15th, 2002, 09:34 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Hi,
Ben's right, and here's the code you need. Firstly, for the login form:

<?php

global $HTTP_COOKIE_VARS;

if($HTTP_COOKIE_VARS["auth"] == true)
{
header("some_other_page.php");
}
else
{
?>

<form action="checklogin.php" method="post">
User: <input type="text" name="user"><br>
Password <input type="password" name="pass"><br>
<input type="submit">

<?php

}

?>

and for checklogin.php:

// do you database stuff here, i will assume you've created
// a variable called $ok which is the result of a call to
// mysql_num_rows("select * from logins where user=...") etc

if($ok == true)
{
setcookie("auth", true);
header("some_other_page.php");
}
else
{
header("location: login.php");
}

that should get you started, let me know if you need more help

Reply With Quote
  #4  
Old April 15th, 2002, 10:13 AM
wAr-AnGeL wAr-AnGeL is offline
Forum Security
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Behind You
Posts: 479 wAr-AnGeL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m
Reputation Power: 7
Send a message via ICQ to wAr-AnGeL Send a message via AIM to wAr-AnGeL
thx for the code, i'll try it

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Using cookies with forms


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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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

Iron Speed




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