Mohit Tripathi
Mohit Tripathi

Reputation: 127

How to manage single session on two different php scripts?

I have installed two different PHP scripts on my server. One on root and another on different sub-directory. However, I want the root phpscript's users session to be continued on another sub-directory script. I need this session to enable chat even on another directory script.

The sub directory is os-class. I made a different PHP file on sub-directory to track session variables.

Array ( [user_email] => [email protected]
        [users_id] => 275
        [first_name] => Sammy
        [last_name] => Durha
        [username] => 275
        [mobile] => XXXXXXXXX
        [chat_sms_sent] => message sent to off line friends. )

However on one of the script page the half session gets lost.

Array ( [messages] => Array ( )
        [keepForm] => Array ( )
        [form] => Array ( )
        [chat_sms_sent] => message sent to off line friends. )

Can anyone please sort out the problem.

Thanks

Upvotes: 0

Views: 115

Answers (2)

Alfred
Alfred

Reputation: 21396

Session is independent of directories and files. It can be used universally. But remember that sessions are less secure.

You may follow a simple tutorial here.

Upvotes: 0

Rijk
Rijk

Reputation: 11301

Sessions are not tied to a directory. If you call session_start() at the top of both scripts, the $_SESSION variable should have the same content in both.

Upvotes: 1

Related Questions