PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

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 Dev Shed Forums Sponsor:
  #1  
Old March 30th, 2000, 10:19 PM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
I am trying to get a handle on setting and retrieving cookies. I think I might have it down, but I'm not sure... if anyone can help, please reply.

to set a cookie, I have only two variables, the user name ($user) and their password ($password)... okay, so I want to set this cookie after they logon.

I use: (this is more of a question than a statement)

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
setcookie("username",$user,time()+31536000);
setcookie("password",$password,time()+31536000);
[/code]

and this should set the cookie(s), right? I think this should go before the <html> or <head> tags in my page (so basically, the VERY first thing in my page should be this, if I'm setting the cookies)


To retrieve the cookies, I use : (again, another question based statement)


<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
....
[/code]

okay, so I don't know how to retrieve information from the cookie.

Any help would be greatly appreciated, correcting my setcookie code, and completing my retrieval information. I am kinda new to php, not totally dumb to programming, but lost on cookies <G>

Thanks,
Mike


Reply With Quote
  #2  
Old March 31st, 2000, 12:06 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
your setup cookie is correct..

i am writing an easy example for cookie:

setcookie("CookieID", $USERID);


To retrieve the cookies from above example you can use..

print $CookieID;

ie,Name of the cookie..


Reply With Quote
  #3  
Old March 31st, 2000, 05:38 AM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
Alright, so if the top of my web page looked like this:

<?php3
setcookie("username",$user,time()+31536000);
setcookie("password",$pwrd,time()+31536000);
?><HTML><HEAD> ...........rest of page ....

that would set my cookie, and later in the site I use $username and $password as my variables to reference their cookie? There's no "getcookie" function or anything?

Thanks,

Mike




------------------

Reply With Quote
  #4  
Old April 4th, 2000, 10:28 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmccue:
Alright, so if the top of my web page looked like this:

<?php3
setcookie("username",$user,time()+31536000);
setcookie("password",$pwrd,time()+31536000);
?><HTML><HEAD> ...........rest of page ....

that would set my cookie, and later in the site I use $username and $password as my variables to reference their cookie? There's no "getcookie" function or anything?

Thanks,

Mike

[/quote]

Hi Mike,

If the cookies have been set, then you can simply refer to their values in other php pages (within the same domain/directory the cookie is set in) with the variables $username and $password.

Try this to see whether the cookies are there:

Make a file (viewcookie.php3 or so), like:

<?
if(isset($username) and isset($username))
{
print $username . "<BR>n";
print $password . "<BR>n";
}
else { print "No cookies have been set!"; }
?>

Have a nice meal!

Peter

[This message has been edited by PAV (edited April 04, 2000).]

Reply With Quote
  #5  
Old April 5th, 2000, 04:45 AM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
Thanks both of ya for your help... I played with it, and got it to work on my third or fourth try.... Kept forgetting the "+" after the "time()" statement....


Just wanted to let ya know your help is appreciated.

Mike


------------------

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Cookies in PHP, real examples?

Developer Shed Advertisers and Affiliates



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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap