turpentyne Posted October 2, 2010 Share Posted October 2, 2010 I'm stumped on this one. New to sessions and cookies. When somebody logs out, the browser goes to logout.php. It logs them out, but the page shows this error: Warning: setcookie() expects parameter 3 to be long, string given in /data/21/2/40/160/2040975/user/2235577/htdocs/logout.php on line 23 you are now logged out. <?php session_start(); if(!($_SESSION[id])){ $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_server['PHP_SELF']); // check for trailing slash if ((subst($url, -1) == '/') OR (substr($url, -1) == '\\') ){ $url = substr($url, 0, -1); } $url .= '/index.php'; header("Location: $url"); exit(); } else { $_SESSION = array(); session_destroy(); setcookie ('PHPSESSID'. '', time()-300, '/', '', 0); } $page_title ='logged out!'; echo ' you are now logged out'; Quote Link to comment https://forums.phpfreaks.com/topic/215007-setcookie-expects-paramater-to-be-long/ Share on other sites More sharing options...
Mchl Posted October 2, 2010 Share Posted October 2, 2010 I believe you typed in a . instead of a , after 'PHPSESSID' Besides, what's the point of setting such a cookie? Quote Link to comment https://forums.phpfreaks.com/topic/215007-setcookie-expects-paramater-to-be-long/#findComment-1118411 Share on other sites More sharing options...
kenrbnsn Posted October 2, 2010 Share Posted October 2, 2010 I believe you want a comma instead of a period following the first parameter. Instead of <?php setcookie ('PHPSESSID'. '', time()-300, '/', '', 0); ?> do <?php setcookie ('PHPSESSID', '', time()-300, '/', '', 0); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/215007-setcookie-expects-paramater-to-be-long/#findComment-1118412 Share on other sites More sharing options...
turpentyne Posted October 2, 2010 Author Share Posted October 2, 2010 That's what I was missing. The coma/period. But now I'm curious about whether or not I need to set that cookie. I'm following a tutorial that had it in the code. Is it not necessary? I thought it was there in case I sign out, but don't close the window or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/215007-setcookie-expects-paramater-to-be-long/#findComment-1118424 Share on other sites More sharing options...
BlueSkyIS Posted October 3, 2010 Share Posted October 3, 2010 i doubt you need to set that cookie. most likely session data is handled automatically by your PHP installation. Quote Link to comment https://forums.phpfreaks.com/topic/215007-setcookie-expects-paramater-to-be-long/#findComment-1118442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.