Current location: Hot Scripts Forums » Programming Languages » PHP » how to convert cookie to string


how to convert cookie to string

Reply
  #1 (permalink)  
Old 06-05-06, 10:46 AM
mathfxr mathfxr is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
how to convert cookie to string

as i know cookie is an object...so how to convert it to string in php ?
Reply With Quote
  #2 (permalink)  
Old 06-05-06, 11:35 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Once a cookie has been read back, it is available as a variable, as a string, no conversion is necessary -
PHP Code:

echo $_COOKIE["TestCookie"]; 

__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #3 (permalink)  
Old 06-06-06, 01:32 AM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts
Quote:
Originally Posted by mathfxr
hello mab,my prob is about cookie.when i try to put a timer at setcookie and when i call the cookie it will not display data but if im not using timer the data seem to be appear..what is the prob ?
I'm feeling nice today.

BTW mathfxr, you should click on the "Reply" button instead of the report button.
__________________
:: ImperialBB :: New version in the works! :: http://www.imperialbb.com ::

:: Have a question about the board? The Rules? An Infraction/Warning? :: Contact Form ::
Reply With Quote
  #4 (permalink)  
Old 06-06-06, 02:39 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
what's the time you set. you have to use something like this:
PHP Code:

setcookie("name""value"time()+60*60*24*356);

// the first 60 are the seconds
// the second 60 are the minutes
// the 24 are the hours
// the 356 are the number of days
// so if you count well, you'll see this cookie will last 1 year, starting from time() (now) :) 
Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #5 (permalink)  
Old 06-06-06, 07:12 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
I realize that English is not a first language for many of the people here (my wife is not a native either.) They have a saying in her country - "North-South question, East-West answer" - meaning the answer has nothing to do with the question. In this case, the actual question has nothing to do with the question.

How does the title of this thread and the question asked in the first post have anything to do with -
Quote:
my prob is about cookie.when i try to put a timer at setcookie and when i call the cookie it will not display data but if im not using timer the data seem to be appear..what is the prob
If you post the code you are using, you can probably get better answers to your questions.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
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
convert each character in string to array robbydweb PHP 9 06-20-09 11:36 PM
Setting a cooke (time it expires) mcrob PHP 4 04-27-05 12:13 PM
Passing info between pages w/ URL HairySpider JavaScript 6 01-09-05 08:47 AM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


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