Backend Development

PHP Session is NULL

Submitted by Venipa, , Thread ID: 21822

Thread Closed
Venipa
venipa.net
Level:
6
Reputation:
91
Posts:
525
Likes:
148
Credits:
6.18K
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

Burned Designs
Web Developer/Designer
Prime
Level:
0
Reputation:
5
Posts:
115
Likes:
9
Credits:
484
14-06-2016, 04:47 PM
#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

Venipa
venipa.net
Level:
6
Reputation:
91
Posts:
525
Likes:
148
Credits:
6.18K
OP
14-06-2016, 04:58 PM
#3
i tried it, still null
/au4to0][Image: ad0png.png]
[Image: view?username=Venipa&style=small]

RE: PHP Session is NULL

Burned Designs
Web Developer/Designer
Prime
Level:
0
Reputation:
5
Posts:
115
Likes:
9
Credits:
484
14-06-2016, 06:01 PM
#4
are you still only using $_SESSION and not $_SESSION['title']
[Image: SIG.PNG]

RE: PHP Session is NULL

Venipa
venipa.net
Level:
6
Reputation:
91
Posts:
525
Likes:
148
Credits:
6.18K
OP
14-06-2016, 06:06 PM
#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

Aisaka
Tomori wa kawaii desu!
Level:
2
Reputation:
177
Posts:
2.61K
Likes:
351
Credits:
18K
14-06-2016, 06:12 PM
#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

Venipa
venipa.net
Level:
6
Reputation:
91
Posts:
525
Likes:
148
Credits:
6.18K
OP
14-06-2016, 07:31 PM
#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: 1 Guest(s)