1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jeka94
3 years ago
6

What code do I have to use in my php if i don’t want my $_SESSION[“variablex”] to destroy? But i already have a session_destroy(

) above the code that needs to be there. Or maybe there is an alternative?
So i want to destroy all my sessions EXCEPT $_SESSION[“variablex”]
Computers and Technology
1 answer:
Vesnalui [34]3 years ago
5 0

Answer:

See Explanation Below

Explanation:

Follow the steps below.

1. Start Session

2. Assign the session you want to preserve ( $_SESSION['variablex'] ) to a variable

3. Destroy all session (including the one you want, $_SESSION['variablex'])

4. Reassign the contents of the variable you created in (1) above to $_SESSION['variablex'].

The code is as follows (comments explain each line)

<?php

session_start(); // Start session

$variable = $_SESSION['variablex'] ; // assign $_SESSION['variablex'] to $variable

session_destroy(); // Destroy sessions

$_SESSION['variablex'] = $variable; // assign $variable back to $_SESSION['variablex'] to

// You can continue your code (if you have any), here

// End of solution

?>

You might be interested in
My sister told me an extremely funny joke. what is the direct object for this sentence ?
bearhunter [10]

Answer:

Explanation:

6 0
2 years ago
Write the algorithm for finding the perimeter of a rectangle using English like form step by step
olya-2409 [2.1K]
L+L+W+W= Permiter
Or Lenght+Lenght+Width+Width= Perimeter
That’s all just add all the 4 sides
8 0
3 years ago
PLS HELP ME!! WILL GIVE BRAINLIEST
Doss [256]
B i think sorry if I’m wrong
5 0
3 years ago
Read 2 more answers
⦁ ¿Cuáles son los recursos naturales que se utilizan en tu comunidad para generar energía eléctrica?
xxTIMURxx [149]
Turbinas de viento y turbinas de agua son utilizadas, entonces la respuesta podria ser viento y agua
7 0
3 years ago
if i were to buy one of these and plug it into a ps4 usb slot would i be able to see it on a tv? cause my hdmi slot on the ps4 i
alisha [4.7K]
It should work unless you did or bought the wrong thing
7 0
3 years ago
Read 2 more answers
Other questions:
  • What is an implicit benefit to Monetary Policy?
    6·1 answer
  • What is the absolute pathname of the YUM configuration file? REMEMBER: An absolute pathname begins with a forward slash
    12·1 answer
  • Me2540 week 5 assignment<br> what do i want to know?
    9·1 answer
  • Answer the following questions using the five different kinds of parallelism techniques: A - Instruction Level Parallelism B - D
    15·1 answer
  • You CANNOT add text to any filled shape.<br> O True<br> False
    8·1 answer
  • Construct a SQL query that displays a list of colleges, their sity/state, the accrediting agency, and whether or not the school
    8·1 answer
  • HELP!!!!!!!
    8·1 answer
  • A company is concerned that hackers may gain access to its computer system or that it may be
    11·1 answer
  • Which of the following statements are true regarding models? Select 3 options.
    10·1 answer
  • You use lpstat and determine that a user named User1 has placed two large print jobs in the queue for Printer1 that have yet to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!