Jump to content

automate/force session destroy and cookie erase


dflow

Recommended Posts

what would be the best way to

automate/force session destroy and cookie erase

i have a facebook iframe, with facebook login which gets the activation token

now the user is not logged out from the login script after he logs out of facebook.

 

any ideas how to force cookie timeout without a logout button?

 

im playing with

<?php
session_start();

//Global User Object Var
//loggedInUser can be used globally if constructed
if (isset($_SESSION['userCakeUser'])) {		
	$obj = casttoclass('stdClass', $_SESSION['userCakeUser']);	
	$_SESSION['userCakeUser'] = $obj;

	$_SESSION['start'] = time(); // taking now logged in time
$_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 1 minute
}
if(isset($_SESSION["userCakeUser"]) && is_object($_SESSION["userCakeUser"]))
{
	$loggedInUser = $_SESSION["userCakeUser"];
}
?>

Link to comment
Share on other sites

Set the cookie to the past.

 

setcookie('cookie', '', time()-60);

 

Note that you can't force a cookie, the browser chooses to accept it or not.

 

ok got these scripts


//login page
$_SESSION["userCakeUser"] = $loggedInUser;
		$_SESSION['start'] = time(); // taking now logged in time
$_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 1 minute for testing
}


//session timetout include on all pages
//Session Destroy
if(isUserLoggedIn()){
$now = time(); // checking the time now when home page starts
$_SESSION['expire'];

    if($now > $_SESSION['expire'])
    {
        session_destroy();  
    }
}

 

is the logic correct?

it doesnt destroy the session

i want to force the user to login each time session was expired

 

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.