Welcome Guest, Not a member yet? Register   Sign In
How to Maintain two sessions in single site....
#1

[eluser]MASS MASS[/eluser]
Can anybody help to handle two session data sequencly........
#2

[eluser]xwero[/eluser]
What do you mean by handling two sessions? A user that has two parallel sessions?
#3

[eluser]esra[/eluser]
Are you trying to simulate multiple treads, possibly by starting a second session for batch processing (generating a PDF or document conversions, etc.) or another form of simultaneous process?
#4

[eluser]MASS MASS[/eluser]
One session for login users....... and

another session for shopping cart( we are implementing shopping cart)
#5

[eluser]tonanbarbarian[/eluser]
store all of the information in the one session
Just make arrays of data in the session
#6

[eluser]MASS MASS[/eluser]
Hi tonanbarbarian.......

Yours is correct in case of registered users..........we can maintain in single session .

what about in case of not register.....how to maintain session....
#7

[eluser]tonanbarbarian[/eluser]
sessions do not HAVE to be used for just registered users. you can use a session to store any information you want
if for example you want to store 2 things in the session, the user_id of the logged in user, and their favorite colour that they picked on one of the pages (just thought of anything for the second)
You would store them in 2 seperate variabled in the session
Code:
$this->session->set_userdata('user_id', $user_id);
$this->session->set_userdata('fav_colour', $fav_colour);

So what I would do then is by default set the user_id to 0. Any user_id that is not 0 is for a registered user.
This is fairly common practice
#8

[eluser]Peter Ivanov[/eluser]
Look at http://www.captain.at/howto-php-sessions.php
#9

[eluser]MASS MASS[/eluser]
I am creating two session .........i am getting that.....problem is (in case destroy session) as shown below


user for login registration(first session )

for login.....following code uses
$userdata_data = array( 'USER_ID' => 'asdfs34534',
);
$this->session->set_userdata($userdata_data);
-------------------------------------------------------------------

shopping cart products(second session)

$products = array( 'products' => 'slkdfj4545',
);
$this->session->set_userdata($products);
-----------------------------------------------------------------

if i use
$this->session->sess_destroy();

It will kill both sessions. so what to do to kill only users session......
#10

[eluser]tonanbarbarian[/eluser]
Code:
$userdata_data = array( ‘USER_ID’ => null,
);
$this->session->set_userdata($userdata_data);
set the user_id to something like null and use that as your check to see if they are logged in or not




Theme © iAndrew 2016 - Forum software by © MyBB