how to use both cookies and files session driver in laravel - php

i have admin and pos page in where all authentication data store in cookies. but now in pos page I, store all products data list in session('products') which is more than 4kb. now i want store the products session in file session driver. when i use the below code in AppServiceProvider; the session driver has set to file and i can't access the page becasue of auth middleware
if (request()->is('admin/*')) {
\Config::set('session.driver','file');
\Config::set('session.cookie', 'file_session');
}

Related

Modify PHP session using session id

If a session id is stored can it be used to alter session data such as an array variable?
I am working on a project for a login system in PHP where the login authentication comes from an out-of-band source (mobile app or browser extension).
The browser page will use JavaScript to continuously request the login state from the server. The user will scan a QR Code on the page for example, and their phone will post their authentication by API to the server.
I would then like to alter the $_SESSION data associated with the session on the page that was issued with that specific QR Code. I can know the session id which issued that specific QR Code which data was returned by the mobile QR Code scan, but can I use the session id to modify the session data, so as to set the SESSION state to logged in?
I have looked through the PHP manual for a function that would allow this to modify another session but didn't find anything. (https://www.php.net/manual/en/ref.session.php)
in view set textbox value with $_SESSION id,
and when action, update data SESSION with id to database.
What you do is you set your session_id to the id data you want to edit then change the session values.
session_id('the id you have');
session_start();
$_SESSION['anydata'] = 'whatever you want';

Can any one explain opencart session in API module?

Session not showing while dump the following session value.
print_r($this->session->data['api_id']);die;
in api/cart/add module.
session variable api_id is set from the admin side. When the admin create or modify any order it create the different session for API user by api login. Check
admin/controller/sale/order.php file

CodeIgniter: How to check if session exists when session library is not loaded

I'm working on some website where I need to load session library, but it must be limited only to places on website where it's really useful, not on all. After all that means, the session library must not be loaded on index page. But there is a problem because on index page I need to display user's data if the user is logged in. What can I do to check if the user is logged in, without loading session library or not creating session cookie on index page?
You can't check whether the user is logged in or not if you don't have an active session on your index page.
Your session must exist in every part of the system execution.
Make the session handler always be available but limit the information you store in the sessions instead of limiting locations in the system of where to use sessions at all.

Maintaining session in php without cookies and without using URL

I have a problem that when a person logs in then he should be restricted to only one IP address. He should not be able to login through different machine at the same time so is there any way to maintain session without using session cookie and without using session id in URL?
yes, by writing session in database. Apart for usual session data (id, and user data) you write and user_ip. So, while session is active you can restrict user access from another ip/machine or even browser (if you set your session uniqueness to be IP and browser headers - user agnet )
Please check link bellow, on how to extend session handler and save/read to/from database (and hence not using cookies)
set session in database in php
and this
PHP user authentication using database and ip address?
You can create a database table that gets updated with a session ID when the user logs in and removed when they logout. At login, you can check the database to make sure there isn't an active session in the DB.

Storing PHP Data in a Cookie

I want to store a database table in a cookie (for example, to store items in a shopping cart for a user that is not logged in).
My problem is, say the table has a list of items where I need to store an ID and amount for each item.
What is a good data structure I could use for PHP to store the data in the cookie?
Cookie Can only store 4KB of session data.You can store the session data in the database or cache in the raw file at server. if you really wish to store the data at client side take a look on some of these javascript storage libraries pablotron , DojoStorage , localstrogage Firefox,Chrome,Safari,Internet Explorer 8+ 5 MB per domain.

Categories