PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 20th, 2013, 07:54 AM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
PHP-General - Session_start() in included/loaded files/pages

Hi,

I remarked I can't put the following code in pages/files I include (php) or load (ajax):
PHP Code:
<?php 
session_start
(); 
if(!
session_is_registered("number")) {
header("location:shoot_nr.php"); 

?>


That means everybody can access those files/pages without first selecting a number if they know the direct url.

Why?

Thx n advance.
kr,
C.

Reply With Quote
  #2  
Old January 20th, 2013, 08:20 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2012
Location: Germany
Posts: 2,041 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 6 Days 22 h 48 m 19 sec
Reputation Power: 812
Hi,

that "session_is_registered" is ancient, where do you even got it from? You're also missing an "exit;" after the redirect, so the PHP code will keep running.

Reply With Quote
  #3  
Old January 20th, 2013, 09:33 AM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
Hi,

that "session_is_registered" is ancient, where do you even got it from? You're also missing an "exit;" after the redirect, so the PHP code will keep running.

But it works, at least for the head page.
In the head page I include one page and I have one link to load another page.

I know it's ancient. PHP manual says:
Quote:
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.


I will try:
PHP Code:
 session_start();
$_SESSION['number'];
if (isset(
$_SESSION['number']){ //do.. } 

Reply With Quote
  #4  
Old January 20th, 2013, 10:30 AM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
Unhappy

It's not working.
Head page:
PHP Code:
<?php 
session_start
(); 
if (!isset(
$_SESSION['number'])) { 
header("Location: shoot_nr.php"); 

?>
//... html page


Included in head page:
PHP Code:
if (!isset($_SESSION['number'])) { 
header("Location: shoot_nr.php"); 



Loaded in head page:
PHP Code:
 session_start(); 
if (!isset(
$_SESSION['number'])) { 
header("Location: shoot_nr.php"); 



Kill session page:
PHP Code:
<?php

session_destroy
();
session_unset();
header("Location: shoot_nr.php");
?>

Reply With Quote
  #5  
Old January 20th, 2013, 12:48 PM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
It works now. I forgot to start the session in kill.php page.
Thx.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Session_start() in included/loaded files/pages

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap