Jump to content
Larry Ullman's Book Forums

Recommended Posts

Do I set the cookie first or session?

<li><?php 					// Create a login/logout link:
					if ( (isset($_COOKIE['user_id'])) && (basename($_SERVER['PHP_SELF']) != 'logout.php') ) {
						if (isset($_SESSION['user_id'])) {
							echo '<a href="logout.php">Logout</a>';
						} else {
							echo '<a href="login.php">Login</a>';
						}
					} else {
						echo '<a href="login.php">Login</a>';
					}
				?></li>

Or do I set the cookie at a later time?  Also, there's a session call in login and then in loggedin, both files need to call for session start? I do not believe you say that anywhere in the chapter if both are required. Thanks

Link to comment
Share on other sites

 Share

×
×
  • Create New...