Jump to content

[SOLVED] session stop?


zang8027

Recommended Posts

I have this php book and it doesn't mention anything about stopping a session.

 

Im using a session to have a log in for this site. Now, i am working on a log out page that will stop the session. Is there a function for that?

 

I guess i could set the session to equal nothing ($_SESSION['priv'] = "") if that even works but is there a better way to make it "sign out" the user?

Link to comment
https://forums.phpfreaks.com/topic/141498-solved-session-stop/
Share on other sites

To stop a session, you simply use

 

session_destroy();

 

 

If you are using Cookies to remember your members log-in, you delete the cookies by setting the time of the cookies to negative

 

As the manual states, callingsession_destroy alone isn't enough to completely kill a session.

Link to comment
https://forums.phpfreaks.com/topic/141498-solved-session-stop/#findComment-740652
Share on other sites

another weird problem. It logs it out BUT i get the following error at the top of the page:

 

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/tyzangme/public_html/ClickNDine/html/logout.php:1) in /home/tyzangme/public_html/ClickNDine/html/logout.php on line 2

 

Warning: Cannot modify header information - headers already sent by (output started at /home/tyzangme/public_html/ClickNDine/html/logout.php:1) in /home/tyzangme/public_html/ClickNDine/html/logout.php on line 9

 

 

Here is my code

 

        <?php
		session_start();
		// Unset all of the session variables.
		$_SESSION = array();

		// If it's desired to kill the session, also delete the session cookie.
		// Note: This will destroy the session, and not just the session data!
		if (isset($_COOKIE[session_name()])) {
    			setcookie(session_name(), '', time()-42000, '/');
		}

		session_destroy();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Click N Dine - Online Food Ordering Service</title>
<meta name="keywords" content="Business Travel, Food, Dine Online, Click And Dine, Eat Online, Local Restaurants" />
<meta name="description" content="Click N Dine offers the ability to recieve food from local restaurants from around your area! No need to pick up the phone, just order online, and wait for it at your door!" />
<link rel="stylesheet" href="../css/global.css" media="screen" type="text/css" />
</head>

<body>
<div id="wrapper">
   		<div id="header">
        	<img src="../Images/siteLogo.gif" alt="Click N Dine" id="mainTitle"/>
            <div class="headerText">
            	<p><b>Welcome </b>-  Have an account already? <a href="login.php">Sign In</a></p>
            	<p><a href="#">My Account </a>|<a href="#"> My Receipts</a> | <a href="#">Customer Feedback</a></p>
            </div><!--headerText -->
        </div><!-- header -->
        
        <div id="navigation">
        	<ul>
            	<li><a href="../index.php">Home</a></li>
                <li><a href="findrestaurants.php">Find Restaurants</a></li>
                <li class="Shopping"><a href"#">Cart</a></li>
            </ul>
        </div> <!--navigation -->
        
        <div class="clearingDiv"></div>
        
        <div id="mainMiddle">
<?php
	print "Signed out succesfully";
?>
        </div>
        
        
        <div id="footer">
        <hr />
        <p><span class="subNavText">Home | Find Restaurants | Shopping Cart | My Account | My Receipts | Customer Feedback</span></p>
         <br />
         <p><span class="subNavText">Company Policy | Privacy Statement | Contact Us | Terms of Service </span></p>
        </div>
        
    </div><!-- Wrapper -->
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/141498-solved-session-stop/#findComment-740655
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.