Drezard Posted September 15, 2006 Share Posted September 15, 2006 Hello, Im using this code to create a cookie:[CODE]<?php$user = $_SESSION['userinfo'];setcookie('user', $user, time()+36000*24*365);session_destroy();?>[/CODE]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 Link to comment https://forums.phpfreaks.com/topic/20843-php-cookies/ Share on other sites More sharing options...
HuggieBear Posted September 15, 2006 Share Posted September 15, 2006 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'RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/20843-php-cookies/#findComment-92270 Share on other sites More sharing options...
Jenk Posted September 15, 2006 Share Posted September 15, 2006 would be better to use [code]<?phpunset($_SESSION['userinfo']);?>[/code]instead of session_destroy() for that scenario, there may be other session data that you want to use later ..[/code] Link to comment https://forums.phpfreaks.com/topic/20843-php-cookies/#findComment-92299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.