Session without the www and with the www php [closed]

2

Hello,

I'm having a problem, it happens that the user logs on to www.mysite.com his session does not stay in mysite.com, why does it have this difference of www and www?

Can anyone help me?

I'm setting the session normally

session_start ();

    
asked by anonymous 03.01.2017 / 13:04

2 answers

1

It has to do with the domain. Some domains are natively suaite.com.br or www.seusite.com.br.

Try setting up the CNAME for your hosting. Some DNSs should point to different places. Consequently generating different sessions.

    
03.01.2017 / 13:12
1

Specify a directory where both can save the session. To do this, use session_save_path () . Read the documentation, the syntax looks something like this:

    <?php 
    ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session'));
    session_start();
?>
    
03.01.2017 / 13:11