Jump to content

Session Variables


gazalec

Recommended Posts

Hi this is going to sound really dumb but how to you set a session variable, i know you can use $_SESSION['variable'];, and i have read about session_register and session_unregister my problem is that at present i am using $_SESSION['variable']; but i dont know how to clear/destroy this because when a Customer enters the website they can login or enter as a guest and if they enter as a guest they can login later, the only problem is when i go to the login later the $_SESSION['variable']; is registered as Guest still so i need to clear this and then reassign them with their customer number

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/41953-session-variables/
Share on other sites

you can just reset the session to something else, i believe.

 

<?php
session_start();

$_SESSION['foo'] = "bar";
echo $_SESSION['foo']."<br>"; //echos bar

$_SESSION['foo'] = "too";
echo $_SESSION['foo']; //echos too
?>

 

but session_destroy clears all data. quote from the php manual:

 

session_destroy -- Destroys all data registered to a session

Link to comment
https://forums.phpfreaks.com/topic/41953-session-variables/#findComment-203401
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.