1

I am not able to get the php session working on http. I tried the same simple test page on another domain on the server which uses https and it worked as expected. Here is the simple code I am using

session_start();
echo session_id();

When I refresh the page I get a new session_id each time. I've set session.cookie_secure to 0 and 1 but it made no difference. I have no clue why this is not working??? Any ideas?

xjx424
  • 173
  • 2
  • 12
  • Are you sure session can write file correctly? Did you try https on actual server, and http on local?Try to check log files. Maybe there's something wrong with permissions. – Mehmet SÖĞÜNMEZ Aug 22 '19 at 20:22
  • I'm able to write, using same user that I am using on https site where it works. Tested both on actual server (same server) and nothing in the log files. I'm thinking it has to do with a setting in php.ini but I've tried every relevant setting I can think of. – xjx424 Aug 22 '19 at 20:30
  • For sessions, php.ini doesn't have that much options. When you open site, check cookies from browser. If you didn't deactive it from ini file, php sets sessionId to cookies. Can you see it? There was an issue on php7 with `session_regenerate_id` method, but i didn't heard an issue about sessionId. – Mehmet SÖĞÜNMEZ Aug 22 '19 at 20:36
  • I see the cookies but only on https, not on http – xjx424 Aug 22 '19 at 21:12
  • I found and other answered question on stacoverflow. can you check it please. https://stackoverflow.com/questions/5921545/php-session-http-to-https-problem – Mehmet SÖĞÜNMEZ Aug 22 '19 at 22:26
  • Possible duplicate of [PHP session HTTP to HTTPS problem](https://stackoverflow.com/questions/5921545/php-session-http-to-https-problem) – Mehmet SÖĞÜNMEZ Aug 22 '19 at 22:26
  • Thanks, saw that already. I'm not switching from http to https or vise versa, only using http when not working – xjx424 Aug 22 '19 at 22:33
  • _“I see the cookies but only on https, not on http”_ - check the actual response for the HTTP version, and see what the Set-Cookie header looks like. – misorude Aug 23 '19 at 08:14

0 Answers0