1
hulk8
How destroy a variable in a session ?
  • 2006/10/15 15:38

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


Hi everobody,


I have a trouble with session in Xoops.
I'm creating a module for my website and I need to keep in stock several values in session. But I also need to destroy this values at a moment. How can I do that ?

I've tried with "session_unregister()" and "unset()" function but that doesn't work.

What must i do, it's rather complex so I can't do it with "POST" and "GET".


Somebody have an idea ?


Thanks a lot for your help,



PS: Sorry for my english but i can't speak english very well but I can read it without problem.

2
Dave_L
Re: How destroy a variable in a session ?
  • 2006/10/15 18:12

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Have you tried unset($_SESSION['variable']) ?

3
hulk8
Re: How destroy a variable in a session ?
  • 2006/10/15 18:38

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


Yes but that doesn't work... unfortunately...


Here the copy/paste of some of my lines:
unset($_SESSION['txt']);
unset(
$_SESSION['heure']);
unset(
$_SESSION['adresse']);
unset(
$_SESSION['contact']);

4
Dave_L
Re: How destroy a variable in a session ?
  • 2006/10/15 19:35

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


And session_start() is called before the unset's?

5
hulk8
Re: How destroy a variable in a session ?
  • 2006/10/15 22:19

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


I suppose because it's in XOOPS et XOOPS uses session to test the right of the user. It's in the admin of the website my problem not in the member area...



[EDIT: 2006/10/16 7:33]

I've just tried to be sure. I've added "session_start();" but that send me an error.
" A session had already been started - ignoring session_start() in file (...)"

[/EDIT]

6
hulk8
Re: How destroy a variable in a session ?
  • 2006/10/16 5:40

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


I've understood.

In case to simplify the explication, i didn't say that

unset($_SESSION['txt']);
unset($_SESSION['heure']);
unset($_SESSION['adresse']);
unset($_SESSION['contact']);

txt, heure, adresse, contact was array and apparently in XOOPS we can't destroy an array with this method.

We must destroy variable by variable.

unset($_SESSION['txt[0]']);
unset($_SESSION['heure[0]']);
unset($_SESSION['adresse[0]']);
unset($_SESSION['contact[0]']);
unset($_SESSION['txt[1]']);
unset($_SESSION['heure[1]']);
unset($_SESSION['adresse[1]']);
unset($_SESSION['contact[1]']);
...

How can I do to destroy the array as a whole ?

7
McNaz
Re: How destroy a variable in a session ?
  • 2006/10/16 8:53

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


I've used unset($_SESSION['var']) is XOOPS with no problems (as seen in xAsset).

8
hulk8
Re: How destroy a variable in a session ?
  • 2006/10/16 10:29

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


If I do unset($_SESSION['var']) on a simple variable, there's no problem in fact but if I do unset($_SESSION['var']) and "var" is an array (var[0],var[1],...), that doesn't work...

9
m0nty
Re: How destroy a variable in a session ?
  • 2006/10/16 10:42

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


my php skills are definitely not skilled,

but can't you write a function that will grab the array data and use a foreach() to unset the returned values from the array?

i can't write the function myself, but that's how i think it could be done, as i say i'm not an experienced coder so i could be completely misunderstanding this.

10
hulk8
Re: How destroy a variable in a session ?
  • 2006/10/16 11:07

  • hulk8

  • Just popping in

  • Posts: 11

  • Since: 2005/3/16


Quote:

m0nty wrote:
but can't you write a function that will grab the array data and use a foreach() to unset the returned values from the array?


If there isn't an other solution, i'll do that.

Login

Who's Online

169 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 169


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits