Search
Left Quote    I find that the harder I work, the more luck I seem to have.
- Thomas Jefferson    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: logout cookies
  This user is offline  what2do
  Subject: "logout cookies" Posted: @ 9:39 pm on Mar 09 2007   
Member #: 299
Rank: User - (3)
Since: 03/09/07
Posts: 3

Hi ive been messing around with the Complete Membership tutorial and i cant get the cookies cleared.

I followed the tutorial plus read some forum posts concerning it and tried the solutions offered but wont log me out.

do i have to include the page header with it?

Code:
<?
$_SESSION['logg ed_in'] = 0;

setcookie('logi n_cookie', "", time() - 60, '/', '.yoursite.com' );

session_destroy ();
header("Lo cation: http://www.your site.com";
?>



Also im using this method to set cookies with login

setcookie('logi n_cookie', $joined, 2147483647, '/', '.www.yoursite. com');

Why does one use www and the logout use just dot?

Edited at 09:48:44 pm on 03/09/07


    Viewed: 7,946 Times | Reply to This | To top
  This user is offline  what2do
  Subject: "re: logout cookies" Posted: @ 10:24 pm on Mar 09 2007    
Member #: 299
Rank: User - (3)
Since: 03/09/07
Posts: 3

Also i noticed REDIRECT TO USERS PROFILE... doesnt do anything if logged in and viewing login page. it just shows login form. and i know im logged in because i redirected it to page with headers included testing if cookie was set or not.

<BR><f ont size=1><u >Code:</u ></font&g t;<BR>< ;div name="div _box" class="di vCode"> ;<?
ob_start();
require_once($_ SERVER['DOCUME NT_ROOT'].'/d b_connect.php' );

if(isset($_SESS ION['username ']) && isset($_SESSION ['password']) ) {
//REDIRECT TO USERS PROFILE...
header("L ocation: http://www.your site.com"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
} //end if logged in

//IF SUBMIT BUTTON PRESSED
if(isset($_POST ['submit'])) {

if(!$_POST['us ername']) die("Erro r: You must enter your username before logging in.";
if(!$_POST['pa ssword']) die("Erro r: You must enter your password before logging in.";

//set cookie if checked
if(!empty($_POS T['stay_in']) ) {
$joined =''.$_POST[' username'].'[ ]'.md5($_POST[ 'password']). '';
setcookie('log in_cookie', $joined, 2147483647, '/', '.www.yoursite .com');
} //end if

//verify user...
$get_user = mysql_query(&q uot;SELECT * FROM `members` WHERE username = '".$_POS T['username'] ."' AND

user_password = '".md5($ _POST['passwor d'])."' ";
$q = mysql_fetch_obj ect($get_user);
if(!$q) die("Logi n Failure: An error occured, please verify your username and password are correct."< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

//set session variables
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $_POST['userna me'];
$_SESSION['pas sword'] = $_POST['passwo rd'];
session_write_c lose();

header("L ocation: http://www.your site.com"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;

} else {
//show login form
?>
<form name="log in" method="p ost" action="& lt;? $_SERVER['PHP_ SELF']; ?>"> ;
<table>
<tr>
<td>Usern ame:<input type="tex t" id="usern ame" name="use rname"> ;</td>
</tr>
<tr>
<td>Passw ord:<input type="pas sword" id="passw ord" name="pas sword"> ;</td>
</tr>
<tr>
<td>Submi t: <input type="sub mit" value="Su bmit" name="sub mit" id="submi t">< ;/td>
</tr>
<tr>
<td>Remem ber? <input type="che ckbox" name="sta y_in[]" checked=" yes">& lt;/td>
</tr>
</table>
</form>
<?
}//end else
?>




Edited at 10:27:02 pm on 03/09/07


    Viewed: 7,931 Times | Reply to This | To top
  This user is offline  what2do
  Subject: "re: logout cookies" Posted: @ 12:55 am on Mar 10 2007    
Member #: 299
Rank: User - (3)
Since: 03/09/07
Posts: 3

Nevermind figured it out was www after all and needed session start on login page.

Thanks anyway




    Viewed: 7,922 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: logout cookies" Posted: @ 4:30 am on Mar 10 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Glad you figured it out! Hope you enjoy the script




-bs0d | AllSyntax.com

    Viewed: 7,916 Times | Reply to This | To top
  This user is offline  roym
  Subject: "re: logout cookies" Posted: @ 10:51 am on Sep 14 2008    

Member #: 752
Rank: User - (9)
Since: 09/12/08
Posts: 9

  what2do said...

< i> Hi ive been messing around with the Complete Membership tutorial and i cant get the cookies cleared.

I followed the tutorial plus read some forum posts concerning it and tried the solutions offered but wont log me out.

do i have to include the page header with it?

Code:
<?
$_SESSION['log ged_in'] = 0;

setcookie('log in_cookie', "", time() - 60, '/', '.yoursite.com ');

session_destroy ();
header("L ocation: http://www.your site.com"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
?>



Also im using this method to set cookies with login

setcookie('log in_cookie', $joined, 2147483647, '/', '.www.yoursite .com');

Why does one use www and the logout use just dot?







i got this same problem and it's my only problem im having right now.
where exactly am i directing them to? ive tried directiong to. i have the session start in my login and also my index. ive tried directing to both but i dont get logged out...




    Viewed: 5,841 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank