Jump to content

setcookie() expects paramater to be long.


turpentyne

Recommended Posts

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';

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.