473,545 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Same SESSID after session_destroy

Mat
Hi,
I'm trying to renew a session by using session_destroy () before
starting a new session on the next page. Unfortunately, it seems that
I keep getting the same SESSID (using $_REQUEST["PHPSESSID"]) when the
session starts again. I made a test page to simplify the problem and
it still happens:

<?
session_start() ;
echo "SESSID = ".$_REQUEST["PHPSESSID"];
session_destroy ();
?>

If I refresh this page, I would expect it to give me a new sessid each
time, but it doesn't. Is there something I'm not understanding here?
I also tried putting a couple of extras in like:

unset($_REQUEST["PHPSESSID"]);
session_unset() ;

Looking forward to hearing from someone!
Thanks,

Mat
Jul 17 '05 #1
2 3297
Mat wrote:
I'm trying to renew a session by using session_destroy () before
starting a new session on the next page. Unfortunately, it seems that
I keep getting the same SESSID (using $_REQUEST["PHPSESSID"]) when the
session starts again.
Yes, that happens. What do you need the session id for?
See below for how I check if a session is new.
I made a test page to simplify the problem and
it still happens:

<?
session_start() ;
echo "SESSID = ".$_REQUEST["PHPSESSID"];
session_destroy ();
?>

If I refresh this page, I would expect it to give me a new sessid each
time, but it doesn't. Is there something I'm not understanding here?
I also tried putting a couple of extras in like:

unset($_REQUEST["PHPSESSID"]);
session_unset() ;

Looking forward to hearing from someone!


<?php
session_start() ;
if (!isset($_SESSI ON['counter'])) $_SESSION['counter'] = 0;

if ($_SESSION['counter'] == 0) {
/* NEW SESSION, probably same id */
echo "NEW SESSION<br/><br/>\n\n";
}

++$_SESSION['counter'];
echo 'session id: ', session_id(), "<br/>\n";
echo 'counter: ', $_SESSION['counter'], "<br/>\n";
if ($_SESSION['counter'] == 3) {
session_destroy ();
session_unset() ;
echo "session destroy'd and unset'd.<br/>\n";
}
?>
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
we*********@mat thewmarlow.com (Mat) wrote in message news:<89******* *************** ****@posting.go ogle.com>...
Hi,
I'm trying to renew a session by using session_destroy () before
starting a new session on the next page. Unfortunately, it seems that
I keep getting the same SESSID (using $_REQUEST["PHPSESSID"]) when the
session starts again.

<snip>

My knowledge is much theoretical and I guess few possibilities for
the cause:

1. session_destroy () destroys the session file on the server. But, it
doesn't remove the session cookie (which holds the session id) or
doesn't remove the trans sid
2. PHP's session is "permissive " which means you can send any session
id to the server and PHP will create a new session (file) if there is
no such session (with the session id that you pass)
3. So, though session_destroy () destroys the session file, the
current session id found in cookie is still passed to the server which
in turn generates the session with same session id. (Untested
suggession: try deleting the session cookie.)

HTH

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2254
by: Ken | last post by:
I am curious how others solve this problem. After storing the data from sessions in the database. How do you handle the session data stored on the server and cookie on the users computer. I know how to destroy the session data and remove the cookie, but how do you handle this problem. I see three possibilities:
3
2026
by: José Landoni | last post by:
Hi, I got a problem with session_destroy function I created a script but it wont work, it goes like this: <?php session_start(); session_unset(); session_destroy(); header(location:index.php); ?>
3
6497
by: Derek Fountain | last post by:
The documentation says session_destroy() "destroys all of the data associated with the current session". Um, like what? The docs further say that you should remove all information in the _SESSION global with $_SESSION = array() and you should use setcookie() to set the session cookie to a blank value. Having done those, what does that leave...
3
2243
by: Remon Huijts | last post by:
Hi, When I use php mail() in a script on my localhost to send an HTML message to an e-mailaccount on my online host, all is fine. When I use php mail() in a script on my online host to send an HTML message to some e-mailaccount other than on my online host, all is fine. But when I use php mail() in a script on my online host to send an...
3
2584
by: Coder Droid | last post by:
Without going into the details of my code: is it possible to have two different users logged in at the same time? I had one page where I found the username correctly set, and another where it wasn't. (Just by checking <?= $_SERVER >? at the top of each page.) Wondering why it would be set for one page and not another (and as a sanity...
18
3369
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password...
7
7542
by: Sharon | last post by:
Hi all, I've implemented a TCP server using the Socket async methods. When connecting to the server from 3 instances of hyper terminal, i've noticed that each of the newly created server sockets, uses the same server port. I assumed that a new connection will receive a unique port. If this is the way its suppose to work, is it a performance...
28
2474
by: SzH | last post by:
Suppose that there is a program that takes two files as its command line arguments. Is there a (cross platform) way to decide whether the two files are the same? Simple string comparison is not enough as the two files might be specified as "file.txt" and "./file.txt", or one of them may be a symlink to the other.
7
1811
by: Jivanmukta | last post by:
Hello, I am learning PHP5. I have a website that consists of two pages: index.php and summary.php. In index.php the user is automatically moved to summary.php with some $_SESSION data so I use session_end instead of session_destroy on index.php page. And the user can manually (hyperlink) go to index.php from summary.php with some $_SESSION...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.