Jump to content


PHP Cookies

  • Please log in to reply
2 replies to this topic

#1 Drezard

  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 15 September 2006 - 09:31 AM

Hello, Im using this code to create a cookie:

$user = $_SESSION['userinfo'];
setcookie('user', $user, time()+36000*24*365);

In a past script that redirects to this one, it sets 'userinfo' as $user. So is this correct (its at the very top of the script).

- Cheers, Daniel

#2 HuggieBear

  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 15 September 2006 - 09:46 AM

It should be fine, so long as $user on the previous page had something assigned to it.

You might want to include a few more parameters in your call to setcookie() though.  Like 'path' and 'domain'

Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Jenk

  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 15 September 2006 - 10:36 AM

would be better to use



instead of session_destroy() for that scenario, there may be other session data that you want to use later ..[/code]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users