Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2004, 03:58 PM
Registered User
 
Join Date: Jul 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Session and Cookie authentification

I know how to handle user authentification through either session variable or cookies, but I was wondering if both could be used simultaneously.

What I want to achieve is a normal session login, but give users the checkbox option to remember the login info for the next time they come to the site. How would I go about achieving this?

 
Old August 30th, 2004, 04:44 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I do this all the time.

What you need to do is have PHP check if the checkbox is checked, and if it is, set a cookie to the username that the user logged in with. Then, on every page of yours, add a bit of PHP that checks for the remember cookie, and if it is set, set the session to logged in.

HTH,

Snib

<><
 
Old August 30th, 2004, 06:52 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Sessions already create cookies. Seems to me the best way to do that is to tweak your session settings to allow sessions to perpetuate between user visits via the session cookie. Have a look at php.ini, there are several settings that allow this.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP session cookie ajit Beginning PHP 0 October 23rd, 2007 11:56 PM
Encrypting session cookie krisXp Classic ASP Databases 1 November 9th, 2006 10:21 AM
Cookie and Session rinventive PHP How-To 0 December 6th, 2005 07:09 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM
Session cookie problem rogierio Classic ASP Professional 0 October 15th, 2003 09:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.