-1

I'm building a PHP application that needs to store sessions withing sessions.

The application I'm building is a Banking/Teller project, a session will be created when the teller logs in, this will always be present until the teller logs out, just like a login/logout system.

However, when the teller enters a customer number this will be looked up inside a database and validated, then another session has to be created to store this temporary information about the customer. This cookie/other method should be deleted and a new once created with a random name the next time a new customer comes around. Should I store this inside the teller session? Create a new session - can you even do this in PHP, multiple sessions? Or should I create a completely separate cookie for the customer session?

Overview:

  1. A login/logout session for the teller - static.
  2. A dynamically changing session for the customer - could be changed every five minuets, just depends on customer flow

What would be the best way to implement this?

Brad Turner
  • 91
  • 1
  • 3
  • 5

1 Answers1

8

Just create your own space in the session for each entity.

<?php
$_SESSION['teller'] = $teller;
$_SESSION['customer'] = $customer;
?>

That way you can destroy the customer data all you want, but if the teller logs out, you can kill all of the data when you destroy session.

I don't see the value in creating two sessions, if that's even possible.

Halfstop
  • 1,710
  • 17
  • 34