Current location: Hot Scripts Forums » Programming Languages » PHP » cookie problem


cookie problem

Reply
  #1 (permalink)  
Old 12-23-03, 07:06 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
cookie problem

hi,

i plan to make a member script and i want to use cookies so the user can stay logged in. now my problem is simply that I dont know how to code in cookies at all could you either show me a code or a tutorial so i know what to do.

now i was going to use sessions but it doesnt keep you logged in and i would like the user to stay logged in for ease.
__________________
Elite Bulletin Board
http://elite-board.us
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 12-23-03, 08:52 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Make the normal login etc.

Then in the header use session_start
if ($_COOKIE['Login_Cookie']) {
// Read cookie (Make it store userid / password hashed with md5) and query against a database.

If it matches up, start the sessions for quick login, if it doesnt then delete the cookie and send a mail with their ip and what they used to try to access the site to yourself as to take legal action if they were trying to exploit something.

Also the php manual includes VERY detailed information on cookies.
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-24-03, 06:38 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-24-03, 10:31 AM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
ok i still dont get it is there a better example cause i really want to use cookies so my users can stay logged in
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 12-24-03, 01:06 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
I gave you more info on how to do it that the person that told me how to do it.

Would you like a full script?
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-25-03, 02:36 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
basically i need to know how to:

create cookies
use them
detect them

now i might just use sessions if i cant figure this out.
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 12-25-03, 03:16 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
create cookie : setcookie();
use cookie : $_COOKIE[]
detect cookie : if ( isset($_COOKIE[]) )

still I gave you the link and you said you didn't understand !! the manual is clear actually VERY clear ...
try again : http://ar.php.net/manual/en/function.setcookie.php
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 12-26-03, 09:22 AM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
ok im getting it now that i read this a 2nd and 3rd time ok thx.
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 12-26-03, 01:53 PM
darkcarnival's Avatar
darkcarnival darkcarnival is offline
PHP/MySQL coder
 
Join Date: Jun 2003
Location: Michigan
Posts: 939
Thanks: 0
Thanked 0 Times in 0 Posts
ok how do u delete cookies? like if a user wants to logout? i check the link and it didnt say how.
__________________
Elite Bulletin Board
http://elite-board.us
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 12-26-03, 02:15 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Set the cookie with time -3600 (minus one hour) then it will be removed.
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
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
checkbox.length problem Hawaii 5-0 JavaScript 3 11-27-03 03:15 PM
Small problem for a pro, but for novice like me... argh! ntek Perl 3 11-19-03 02:45 PM
file download problem ukyankee Perl 6 10-04-03 11:39 PM
jpGraph axis labeling problem Squeezer PHP 2 08-20-03 08:53 AM
Weird cookie request. grawss Script Requests 0 07-19-03 11:30 PM


All times are GMT -5. The time now is 11:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.