user3850805 user3850805 - 3 months ago 23
Ajax Question

SESSION lost after location.reload()

I am trying to make login using ajax to send username and password to my php script for checking if there is any record in database, on my ajax success i want to reload the page in order to show something if session is created. I use session start on very top of my pages. Also on local server my login works perfect, but on ipage server i have this problem with losing session...(i tested it using var_dump($_SESSION) and its always

array (size=0) empty
)
I have also tried using this on my very top of pages:

session_save_path("your home directory path"/cgi-bin/tmp);
session_start();


but this also didn't work...
Also i have tried to change
session.save_path
but still same.

I am sorry for my bad English.

EDIT:
I`ve tried using form to create login but same issue still going on. Its clear now that something with the server is wrong.(maybe with the php.ini)

Answer

It turns out that my host changed servers and started using a different session save path other than /var/php_sessions which didn't exist anymore. A solution would have been to declare ini_set(' session.save_path','SOME WRITABLE PATH'); in all my script files but that would have been a pain. I talked with the host and they explicitly set the session path to a real path that did exist. Hope this helps anyone having session path troubles.

Location of session folder:

/domains/account/session

location of index.php

/domains/account/public_html/index.php

What I placed in index.php at line 0:

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

This is the only solution that worked for me. Hope this helps someone.