Current location: Hot Scripts Forums » Programming Languages » PHP » Delete session and cookie


Delete session and cookie

Reply
  #1 (permalink)  
Old 08-28-06, 01:10 PM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
Delete session and cookie

I have the following code:

PHP Code:

if ($_GET['do'] == 'logout') {


session_start();
$_SESSION['username'] = "";
$_SESSION['uid'] = "";
$_SESSION['foldername'] = "";
session_destroy();
 
setcookie(session_name(), ''''"/");

Why I get this error ? :

Code:
Warning: setcookie() expects parameter 3 to be long, string given in /home2/devfirst/public_html/login.php on line 19

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/devfirst/public_html/login.php:19) in /home2/devfirst/public_html/login.php on line 65

Warning: Cannot modify header information - headers already sent by (output started at /home2/devfirst/public_html/login.php:19) in /home2/devfirst/public_html/login.php on line 66
The cookie is created with following line :

PHP Code:

setcookie(session_name(), session_id(), time()+900"/" ); 


Last edited by nico_swd; 08-28-06 at 01:23 PM. Reason: Please use [php] wrappers when posting php code. :)
Reply With Quote
  #2 (permalink)  
Old 08-28-06, 01:22 PM
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
Quote:
Warning: setcookie() expects parameter 3 to be long, string given in /home2/devfirst/public_html/login.php on line 19

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/devfirst/public_html/login.php:19) in /home2/devfirst/public_html/login.php on line 65

Warning: Cannot modify header information - headers already sent by (output started at /home2/devfirst/public_html/login.php:19) in /home2/devfirst/public_html/login.php on line 66
the first error is because you entered a string when there should be a number inserted. this is on this line:
PHP Code:

setcookie(session_name(), ''''"/"); 

if you check the php manual, you'll see what needs to be inserted.

the second error means that you allready displayed something before starting the sessions. this may not according to php manual

the third error is about the same as the second: you try to send a user to a different page using the header function. you may not display anything before using the header function. nothing may be outputted, not even html on a differetn page

Greetz,
Unrealed
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

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
cannot send session cookie - headers already sent? littleacorn PHP 12 07-17-06 12:18 PM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
Think Like a Hacker DAL PHP 18 05-22-06 07:18 PM
Setting a cooke (time it expires) mcrob PHP 4 04-27-05 12:13 PM
Session vs. Cookie Mister B. PHP 3 09-09-04 06:49 PM


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