Current location: Hot Scripts Forums » Programming Languages » PHP » COOKIE and SESSION


COOKIE and SESSION

Reply
  #1 (permalink)  
Old 02-17-05, 08:31 AM
mhs12grade1992's Avatar
mhs12grade1992 mhs12grade1992 is offline
Newbie Coder
 
Join Date: Feb 2005
Location: USA
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
COOKIE and SESSION

What's the difference between $_COOKIE and $_SESSION?
__________________
Sincerely,
MHS (Mansfield High School)

Create your own short/long story within few minutes.
Simply fill out the form and it will write the story itself.

Go to: www.storymakerpro.com

Am I rich in million or just my 2 cents poor?
Reply With Quote
  #2 (permalink)  
Old 02-17-05, 08:56 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
cookies and session files are mere text files..
cookies are saved on the visitors machine while session files are saved on the server.
which makes session more secure than cookies..
tha advantage of cookies over sessions is that cookies can be saved and recognized for a long time! while session is only valid for ..... a session
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 02-17-05, 09:16 PM
mhs12grade1992's Avatar
mhs12grade1992 mhs12grade1992 is offline
Newbie Coder
 
Join Date: Feb 2005
Location: USA
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Is $_COOKIE easier than $_SESSION? I'd rather to use $_COOKIE is because of name and value. $_SESSION does not run the same.
__________________
Sincerely,
MHS (Mansfield High School)

Create your own short/long story within few minutes.
Simply fill out the form and it will write the story itself.

Go to: www.storymakerpro.com

Am I rich in million or just my 2 cents poor?
Reply With Quote
  #4 (permalink)  
Old 02-17-05, 10:55 PM
phprogramming phprogramming is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
u can save a cookie to always run a session, u can use cookies alone, sessions alone, or cookies and sessions together which is most oftenly the most convenient and best way to go about using cookies and sessions
__________________
Source Code Talk - Programming Discussion, Tutorials, and More!
Reply With Quote
  #5 (permalink)  
Old 02-18-05, 01:50 PM
mhs12grade1992's Avatar
mhs12grade1992 mhs12grade1992 is offline
Newbie Coder
 
Join Date: Feb 2005
Location: USA
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
So if I want to save data on my server without storing cookies in a hard drive is by using $_SESSION?? Sound like I don't want to use MySQL for storing my datas, instead, I store them into server cookies. All datas can only be saved on a next page using POST method without cookies and sessions. I would carry all arrays/datas via cookies/sessions.

So would you say SESSION is a lot better and useful than COOKIE??
__________________
Sincerely,
MHS (Mansfield High School)

Create your own short/long story within few minutes.
Simply fill out the form and it will write the story itself.

Go to: www.storymakerpro.com

Am I rich in million or just my 2 cents poor?
Reply With Quote
  #6 (permalink)  
Old 02-18-05, 03:13 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
you can NOT replace MySQL with session files! session files get deleted after the user closes his/her browser..
you could use flat files instead but why would you do that when you have MySQL? MySQL is much faster and easier to deal with..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #7 (permalink)  
Old 02-19-05, 01:08 PM
mhs12grade1992's Avatar
mhs12grade1992 mhs12grade1992 is offline
Newbie Coder
 
Join Date: Feb 2005
Location: USA
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Because I am having trouble with MySQL ..... receiving data. I use mysql_fetch_array() but it always show "Array" as text data.
__________________
Sincerely,
MHS (Mansfield High School)

Create your own short/long story within few minutes.
Simply fill out the form and it will write the story itself.

Go to: www.storymakerpro.com

Am I rich in million or just my 2 cents poor?
Reply With Quote
  #8 (permalink)  
Old 02-19-05, 02:58 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
as I posted before in your other topic, learn how to work it out!
don't expect to get it to work when you don't know how!
the text ypu tried to print was always "Array" because you were trying to echo an array! it's a simple as that!
you need to read more about arrays and how you access its elements and how mysql_fetch_array() actually fetches data from the database..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 02-19-05 at 03:02 PM.
Reply With Quote
  #9 (permalink)  
Old 02-19-05, 09:49 PM
mhs12grade1992's Avatar
mhs12grade1992 mhs12grade1992 is offline
Newbie Coder
 
Join Date: Feb 2005
Location: USA
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
I did follow the book and I did use mysql_fetch_array() but never get a real data. All I got is "Array". There has to be way to get a real data. I believe that book is totally wrong!
__________________
Sincerely,
MHS (Mansfield High School)

Create your own short/long story within few minutes.
Simply fill out the form and it will write the story itself.

Go to: www.storymakerpro.com

Am I rich in million or just my 2 cents poor?
Reply With Quote
  #10 (permalink)  
Old 02-20-05, 12:09 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by mhs12grade1992
I did follow the book and I did use mysql_fetch_array() but never get a real data. All I got is "Array".
That's because you tried to print the array as a normal variable. Try "print_r($my_array);" to print an array and see all the values.


Quote:
Originally Posted by mhs12grade1992
There has to be way to get a real data.
No offense, but you really need to pick up the basics of PHP before you go any further.


Quote:
Originally Posted by mhs12grade1992
I believe that book is totally wrong!
I'll bet you cash it's not.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
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
Server side variables Puno PHP 13 08-13-05 10:22 PM
Session vs. Cookie Mister B. PHP 3 09-09-04 06:49 PM
Setting a cookie within an HTML file using SSI abtimoteo Perl 1 06-19-04 02:09 AM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 12:00 PM
Cannot send session cache limiter??? egzz PHP 1 11-20-03 12:53 PM


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