1

All,

Probably a stupid question, but I'm developing a small site using WAMP (and Firefox to display the HTML produced), and I can't find a way to start my site with a new session. The session persists from one window to the next, with all the user data in session, page count, etc.

How can I start a new session?

Thanks,

JDelage

EDIT: Related thread of interest to others: Firefox session cookies

Community
  • 1
  • 1
JDelage
  • 13,036
  • 23
  • 78
  • 112

2 Answers2

3

A session is a combination of a client-side token (stored in Firefox) and PHP remembering some server-side session information for that token.

If you want to destory the session client-side, you should clear your cache (or start a new private window). If you want to destroy the session information server-side, you should call

session_destroy();

See here for a good tutorial in PHP: http://www.tizag.com/phpT/phpsessions.php

Willem Mulder
  • 12,974
  • 3
  • 37
  • 62
1

Browser based options

Start a new browser session

If you can use Chrome then you can use the File -> New Incognito Window option.

In Firefox it is Tools -> Start Private Browsing.

These will start clean sessions in your browsers.

Delete the session cookie

You can delete the session cooking using the cookie management screen of your browser.

From PHP

You can create a simple script that destroys your session when it is called. For example you can have logout.php:

session_start();
session_destroy();

The manual page is over at session_destroy().

Treffynnon
  • 21,365
  • 6
  • 65
  • 98
  • Thanks. I added a link to `session_destroy()` in my dvp code. It's easier than to toggle endlessly the `private browsing` setting. – JDelage Feb 06 '12 at 15:06