When i log on to my site and click a link in it. It is logging out automatically.
username: demo and Password: demo

can any one say me what may be wrong with this site. Please reply me.

Dani AI

Generated

Several members (, , ) reported no logout when testing 's site. That pattern usually means the problem is environmental or configuration-related rather than a generic bug in the application. Common culprits are session cookies not being sent or preserved, session initialization placed after output, host/protocol mismatches (www vs non‑www, http vs https), or multi‑server setups with no shared session store.

Quick checklist to isolate and fix the issue:

  • Confirm session_start() runs at the very top of every page (before any HTML or whitespace). See the session_start documentation.
  • Inspect the browser’s cookie storage to verify the session cookie (PHPSESSID or custom name) is created at login and present on subsequent requests. If the cookie is missing on the next page load, check whether links point to a different host or switch between HTTP and HTTPS.
  • Ensure cookie domain/path covers all hosts in use (example: set domain to .example.com to cover both example.com and www.example.com).
  • On load‑balanced sites confirm sessions are stored centrally (Redis, memcached, or shared filesystem) or use sticky sessions; otherwise requests can hit a different server that has no session data.
  • Review php.ini session settings such as session.cookie_lifetime, session.gc_maxlifetime, session.save_path, and session.use_only_cookies.

A minimal example to set cookie domain and start a session:

<?php
// older PHP style
session_set_cookie_params(0, '/', '.example.com');
session_start();

// PHP 7.3+ array form
session_set_cookie_params([
  'lifetime' => 0,
  'path' => '/',
  'domain' => '.example.com',
  'secure' => false,
  'httponly' => true,
  'samesite' => 'Lax'
]);
session_start();
?>

For deeper debugging, log session_id() and key session variables immediately after login and on the next page, and check webserver/PHP error logs for "headers already sent" or session warnings. For details on cookie parameters and php.ini options refer to the PHP manual: session_set_cookie_params and session configuration.

Recommended Answers

All 3 Replies

worked perfectly for me. no idea what the problem is.

Maybe you need to clear your cache, history as it works fine for me also.

Looks nice as well....

yeh, works for me aswell, the session isnt destroyed.
try clearing your cache and cookies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.