Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
What is the difference between Session and Cookie?
Old 10-14-2008, 01:32 AM What is the difference between Session and Cookie?
Skilled Talker

Posts: 51
Name: Carol Thomson
Trades: 0
Please anybody tell me the diffrence between Session and cookie in PHP.
carol123 is offline
View Public Profile Visit carol123's homepage!
 
 
Register now for full access!
Old 10-14-2008, 02:15 AM Re: What is the difference between Session and Cookie?
abhi's Avatar
Super Talker

Posts: 100
Name: abhishek
Location: mauritius
Trades: 0
follow this link, you will get the answer and other stuff related to programming. You will get your ans too.
http://www.w3schools.com

anyway..

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too.

session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.
__________________

Please login or register to view this content. Registration is FREE
Visit Mauritius Island for your holidays!
Please login or register to view this content. Registration is FREE
abhi is offline
View Public Profile Visit abhi's homepage!
 
Old 10-14-2008, 02:39 AM Re: What is the difference between Session and Cookie?
Skilled Talker

Posts: 51
Name: Carol Thomson
Trades: 0
Thanks to give me answer.
What functions are used in Cookie?
carol123 is offline
View Public Profile Visit carol123's homepage!
 
Old 10-14-2008, 03:09 AM Re: What is the difference between Session and Cookie?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by carol123 View Post
Thanks to give me answer.
What functions are used in Cookie?
Go here:
Code:
http://www.quirksmode.org/js/cookies.html
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
View Public Profile
 
Old 10-14-2008, 03:23 AM Re: What is the difference between Session and Cookie?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Cookie is an object. Session is a process. Cookie is an identifier stored on client. Session is used for storing data on server between client requests. Session identifier can be passed as cookie value or as GET/POST parameter (which in general is absolutely the same thing).
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
View Public Profile Visit mtishetsky's homepage!
 
Old 10-14-2008, 09:37 AM Re: What is the difference between Session and Cookie?
Novice Talker

Posts: 8
Name: qammar feroz
Location: Pakistan
Trades: 0
Hi There!

cookie is just a peace of information tht is stored on client machine permanently (as for as the user do not delete the cookie, or the cookie is not expire.).

Where session is a process that also keep some information (temporarly )about users and users machines. tht will retain untill user do not close the browser window.

This is the main diff according to my knowledge.

Qamar
__________________
No # 1 FREE Domain Name Low Cast High Quality Web Site Development and Web Hosting
Click Here

Please login or register to view this content. Registration is FREE
qammar is offline
View Public Profile Visit qammar's homepage!
 
Old 10-15-2008, 03:54 AM Re: What is the difference between Session and Cookie?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
OMG

"Where session is a process that also keep some information (temporarly )about users and users machines. tht will retain untill user do not close the browser window."

Physically session is represented with a file that is stored on the server's HDD. When you do session_start() in your script php engine checks for the cookie named after session_name() (which is by default PHPSESSID). If the cookie exists, php tries to find the corresponding file (called session file) and load variables from it. If the cookie does not exists, php creates new session file and sets the cookie. If you need to close the session you may simply unset the cookie which stores the session ID.

Session files are deleted automatically by php according to garbage collection settings. You can learn more about php garbage collection in php manual.

Considering what gammar said about "until user closes the browser window": since session is controlled by cookie you should set correct expiration time to your session cookies. Read the manual about setcookie() to learn how to set cookies which expire on browser window closing and how to set cookies that remain alive during the specified period of time. Settings are same for setcookie() and for session_set_cookie_params().
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
View Public Profile Visit mtishetsky's homepage!
 
Old 10-16-2008, 08:38 PM Re: What is the difference between Session and Cookie?
JohnColonJr's Avatar
Novice Talker

Posts: 7
Name: John Colon Jr
Location: Boston
Trades: 0
Without cookies, websites and their servers have no memory. A cookie, like a key, enables swift passage from one place to the next. Without a cookie every time you open a new web page the server where that page is stored will treat you like a completely new visitor.
__________________
John Colon Jr
Leadsoft Consulting
Boston, MA
JohnColonJr is offline
View Public Profile
 
Old 10-18-2008, 02:27 AM Re: What is the difference between Session and Cookie?
Novice Talker

Posts: 8
Name: qammar feroz
Location: Pakistan
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
OMG

"Where session is a process that also keep some information (temporarly )about users and users machines. tht will retain untill user do not close the browser window."

Physically session is represented with a file that is stored on the server's HDD. When you do session_start() in your script php engine checks for the cookie named after session_name() (which is by default PHPSESSID). If the cookie exists, php tries to find the corresponding file (called session file) and load variables from it. If the cookie does not exists, php creates new session file and sets the cookie. If you need to close the session you may simply unset the cookie which stores the session ID.

Session files are deleted automatically by php according to garbage collection settings. You can learn more about php garbage collection in php manual.

Considering what gammar said about "until user closes the browser window": since session is controlled by cookie you should set correct expiration time to your session cookies. Read the manual about setcookie() to learn how to set cookies which expire on browser window closing and how to set cookies that remain alive during the specified period of time. Settings are same for setcookie() and for session_set_cookie_params().
okay ...

session_start() is not a function ?

function is != method ?
method is ! = process ?

did not i mention that the information in cookie will be ramain as for as cookie not expire or user not delete it ? ?? ?

and when a user colose his/her browser window session not expire ? ? ??

wht is the logic behing session_start() function ? ? ??


Regards.
Qammar Feroz
__________________
No # 1 FREE Domain Name Low Cast High Quality Web Site Development and Web Hosting
Click Here

Please login or register to view this content. Registration is FREE
qammar is offline
View Public Profile Visit qammar's homepage!
 
Old 10-18-2008, 05:46 PM Re: What is the difference between Session and Cookie?
Junior Talker

Posts: 3
Trades: 0
The main use for cookies i see are logins to remember a user.
__________________
freehostedscripts.net
freescripts is offline
View Public Profile Visit freescripts's homepage!
 
Old 10-27-2008, 04:43 AM Re: What is the difference between Session and Cookie?
Average Talker

Posts: 24
Name: aathuls
Trades: 0
Cookies are stored in a client side and the sessions are stored in server side.
__________________
aathul
aathuls is offline
View Public Profile
 
Closed Thread     « Reply to What is the difference between Session and Cookie?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.77236 seconds with 12 queries