Backend Development

PHP Session is NULL

Submitted by Venipa, , Thread ID: 21822

Thread Closed
14-06-2016, 04:08 PM
This post was last modified: 14-06-2016, 05:00 PM by Venipa
#1
http://stackoverflow.com/questions/37812...on-is-null
^ Dont really want to describe it here again.

Request to upload.php (image):
[Image: gmpnvs.jpg]
Website to check it: https://temp.venipa.net
/au4to0][Image: ad0png.png]
[Image: view?username=Venipa&style=small]

RE: PHP Session is NULL

#2
Have you tried if(empty()) ?

PHP Code:
<?php
  
if(empty($_SESSION['test'])){
   
session_start();
   
$_SESSION['test'] = "Session has started";
   
print_r($_SESSION['test']);
   echo 
"<a href='destroy.php'>Destroy</a>";
  }else{
   die(
"Session is not started");
 }
  
?>

Or if you still prefer using !isset

PHP Code:
<?php
  
if(!isset($_SESSION['test'])){
   
session_start();
   
$_SESSION['test'] = "Session has started";
   
print_r($_SESSION['test']);
   echo 
"<a href='destroy.php'>Destroy</a>";
  }else{
   die(
"Session is not started");
 }
  
?>


Destroy.php

PHP Code:
<?php
  session_destroy
();
  
header("refresh:0; url=index.php");
?>
[Image: SIG.PNG]

RE: PHP Session is NULL

OP
#3
i tried it, still null
/au4to0][Image: ad0png.png]
[Image: view?username=Venipa&style=small]

RE: PHP Session is NULL

#4
are you still only using $_SESSION and not $_SESSION['title']
[Image: SIG.PNG]

RE: PHP Session is NULL

OP
#5
14-06-2016, 06:01 PM
BurnedDesigns Wrote:
are you still only using $_SESSION and not $_SESSION['title']

i use $_SESSION['user_session'] to check it, since there's nothing wrong
/au4to0][Image: ad0png.png]
[Image: view?username=Venipa&style=small]

RE: PHP Session is NULL

#6
14-06-2016, 06:06 PM
Venipa Wrote:
14-06-2016, 06:01 PM
BurnedDesigns Wrote:
are you still only using $_SESSION and not $_SESSION['title']

i use $_SESSION['user_session'] to check it, since there's nothing wrong

Why do you want to check
Code:
if (!isset($_SESSION))"
in the first place?
Why don't you just session_start() at the beginning of your php files? It won't harm you and your session won't get overwritten
Aisaka Squad
Clxud | @231 | Kyoko |@1126 |@1256 | @5056 | @25108| @3747

[Image: yrNnxfb.gif]

RE: PHP Session is NULL

OP
#7
Already fixed it, thanks to Burned Designs !
Got that simple thing was the issue, you cant bind the session value with PDO
/au4to0][Image: ad0png.png]
[Image: view?username=Venipa&style=small]

Users browsing this thread: 5 Guest(s)