1
$_SESSION Not working on CPANEL.

When we uploaded it to the web host using CPANEL the $_SESSION is not working. But in local using XAMPP it is working.

Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73

5 Answers5

2

Sessions are enabled by default within any PHP installations and hence do not need any special configuration to enable sessions.

You should make sure you have session_start(); as the first line in any page where you want to use sessions; it should be the very first line, before any whitespace (an empty line, for example).

Hope it helps you.

Jenis Patel
  • 1,617
  • 1
  • 13
  • 20
1

you have make sure to write <?php session_start();?> in the first line of page

waroa kawa
  • 29
  • 8
  • Voting down as this was already answer in 2017 by multiple users. Adding more duplicate answers isn't productive. – hansfn Aug 11 '23 at 13:24
0

you should insert session_start() in the beginning of the script. Make confirm you call it on every page you need the access to session variables as well

Sankar Smith
  • 338
  • 1
  • 5
  • 14
0

Solved! the problem is, I put all my session on other php file so when include the php I put it under the html code.
I mean like this:

<html> <?php ?> </html>

so when I update it to this

<?php ?> <html>

all stuff are good. thanks for the comment guys <3

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
-1

Place your session_start() at top of your page or header before the actual html

Toby
  • 1
  • Thanks for contributing, but this is already mentioned in existing answers. Please take time to read, before adding your own. – hansfn Aug 11 '23 at 13:21