473,508 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_SESSION unset for other user

Hello

I have application in php where users login and logout.
I wanted to create function for administrator which will
delete all session's data for other users.
For example, each user session data is written in:
$_SESSION['$username']['data']

I wanted to delete such information from administrator account.
$session_data = $_SESSION['$username']['data']
unset($session_data)
I provide username - and appripriate username session data is deleted.

But i receive error that $_SESSION['$username']['data'] does not exist.
I suppose that it's because of that it's stored in $users session - not
administrator session.
Is there any way to delete some information stored in somebody's else
session ?
Thanx
Jan 3 '07 #1
5 2312
"avlee" <xx@wp.plwrote in message news:op.tlkugdal1sq83a@saturn...
Hello

I have application in php where users login and logout.
I wanted to create function for administrator which will
delete all session's data for other users.
For example, each user session data is written in:
$_SESSION['$username']['data']

Single quotes and variables don't mix. Use $_SESSION[$username] or
$_SESSION["$username"], but not $_SESSION['$username']. '$username' means
literally a string $username, the variable is not replaced in the string
like it does when "$username" is used... Try this:

$foo = bar;
echo '$foo'; // prints: $foo
echo "$foo"; // prints: bar
echo $foo; // prints: bar

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Jan 3 '07 #2
On Wed, 03 Jan 2007 13:15:11 +0100, David Gillen <Be****@RedBrick.DCU.IE
wrote:
avlee said:
>I have application in php where users login and logout.
I wanted to create function for administrator which will
delete all session's data for other users.
For example, each user session data is written in:
$_SESSION['$username']['data']

I wanted to delete such information from administrator account.
$session_data = $_SESSION['$username']['data']
unset($session_data)
I provide username - and appripriate username session data is deleted..

But i receive error that $_SESSION['$username']['data'] does not exist.
I suppose that it's because of that it's stored in $users session - not
administrator session.
Is there any way to delete some information stored in somebody's else
session ?
Technically yes. Delete all the session files on disk.
Of course this will also delete your own session, although you could use
your
session id and filter out deleting that file.
I would NOT advise doing this though.

Depending what exactly you are trying to do and why, there may be waysto
program around it. For example forcing a session reset using a flag ina
database which other session would then check to see if they need to
delete
their own data.
the problem is that i want to delete other users session data while he is
idle
(but only in very specified circumstances). So i can not set session
timeout.
I can not do it from that user's session too (because he is idle - and
i do not want to do any refresh).
I wanted to do it from other user's session (administrator session -
because i know that code will be called
periodically). Is there any other way ? (except deleting files) ?
Thanx
Jan 3 '07 #3
A better way might be to flag that user in db, Then next time they try
and
do anything you see the flag is set so you destroy their session. Not
exactly
what you want, but them same effect ultimately. And a preferable way of
doing
it too I think.
i did it better way:)

thanx!
Jan 3 '07 #4
On Wed, 03 Jan 2007 15:05:30 +0100, avlee wrote:
i did it better way:)
just because i am curious, how did you do that ?
Jan 3 '07 #5
e:
On Wed, 03 Jan 2007 15:05:30 +0100, avlee wrote:
>i did it better way:)

just because i am curious, how did you do that ?
just like you said, i set a special flag in database, and check it later
when other
clients tried to access my application. If they were on a "clear session
data list"
it was performed :)

Thanx !
Jan 3 '07 #6

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

Similar topics

3
14888
by: Phil Powell | last post by:
PHP: unset($_SESSION); In my original environment (PHP 4.3.2) this line will delete the session variable 'mainDisplay'. But in the testing environment (PHP 4.3.6) the variable persists even...
7
1862
by: DartmanX | last post by:
I have created a wizard which walks a user through a process of selecting data to be generated into an XML file. Each page adds its own data to $_SESSION, until the final page. On this page, an...
2
1639
by: Chuck C | last post by:
Is there a way to access the values from a session by using an index/count instead of the name? Something like: $_SESSION Also, can you query the name and value for this? What I am...
21
3030
by: axlq | last post by:
Someone please tell me if I've discovered a PHP bug. I'm sitting in front of several computers on my home network, behind a NAT firewall/router. I am testing my web site on these different...
2
1556
by: Iain Adams | last post by:
Hey i have a loop like so, foreach($users as $user) { foreach($syncWebUsers as $sync) { //user already synched if($sync == $user) {
5
2284
by: comp.lang.php | last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA $_POST if ($_POST && (!is_array($leaseObj->errorArray)...
2
2019
by: gm04030276 | last post by:
hey, i'm basically trying to use php sessions and a bit of javascript to make tabbed browsing within a web page using sessions to store the data of the different opened pages. Problem: when i unset...
2
2256
by: sharonDonnelly | last post by:
Hi Really dumb problem that's got me beat. Can someone help. The prolem: I'm trying to count the number of times an item has been clicked. There are many items. I want to create a session...
4
1800
TheServant
by: TheServant | last post by:
Hi guys, This is my situation. I have 3 sets of data used on every page of my website. Two of these never change, and the reason they are stored in MySQL and recalled into the $_SESSION variable is...
0
7224
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,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7038
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...
1
5049
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...
0
4706
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...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.