JDelage
JDelage

Reputation: 13682

How to start a new session (PHP, WAMP)?

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

Upvotes: 1

Views: 3967

Answers (2)

Treffynnon
Treffynnon

Reputation: 21563

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().

Upvotes: 1

Willem Mulder
Willem Mulder

Reputation: 13994

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

Upvotes: 3

Related Questions