#1 (permalink)  
Old 08-12-2006, 06:57 PM
Registered User
 
Join Date: Jul 2006
Posts: 18
Unhappy "session validation checking" in html page ...HELP

hey all,

I have a question about checking session in html page:
The variables that is sent through all pages is "user logged in name",and the session name is =username as well,

I added a php condition in html page to check if the session variable was null (null if anybody tried to access without logging in) or not>>if yes redirect to login page else view the page....but its not working properly :S
the goal is no user will be able to access this html directly without logging in.

piece from the code:
HTML Code:
<?php
session_start();
if(! $_SESSION['ses_name']){
  header("Location: http://home/project/login.html");
exit;
                               }
?>

<html>
<head>
<title>Insert record</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body {
	background-color: #EEEEEE;
}
hope I'll find some help,
Reply With Quote

  #2 (permalink)  
Old 08-14-2006, 11:01 AM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
Looking good!

Also, if you are checking or "null", use is_null(). By the way, since I think you will need those next - there's also isset() and empty().

Cheers,
Till

P.S.
Make sure to fix the redirecting link before you put it online.
Reply With Quote
  #3 (permalink)  
Old 08-14-2006, 11:02 AM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
I totally forgot, use this to check what is in $_SESSION (after session_start()):

PHP Code:
echo '<pre>'var_dump($_SESSION); echo '</pre>'
Reply With Quote
  #4 (permalink)  
Old 08-15-2006, 01:58 PM
Registered User
 
Join Date: Jul 2006
Posts: 18
hey Till,

PHP Code:
echo '<pre>'var_dump($_SESSION); echo '</pre>'
It did print the session name...but the code is not working ...I mean even if the session name was null it allows the access.

PHP Code:
<?php
session_start
();
if(
is_null()){
  
header("Location: http://home/project/login.html");
exit;
                               }
?>
Not working I can access the page without logging in

thanx
Reply With Quote
  #5 (permalink)  
Old 08-15-2006, 02:06 PM
Till's Avatar
Administrator
 
Join Date: Jan 2002
Location: Berlin, Germany
Posts: 1,453
PHP Code:
<?php
session_start
();
if(
is_null($_SESSION['ses_name']))
{
  
header("Location: http://home/project/login.html");
  exit;
}
?>
But I would use:

PHP Code:
<?php
session_start
();
if(!isset(
$_SESSION['ses_name']) || is_null($_SESSION['ses_name']))
{
  
header("Location: http://home/project/login.html");
  exit;
}
?>
Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
framespacing="0" problem solved cssiscool Programming and Scripting 4 06-14-2007 08:27 AM
html web page with power point slide or flash zillah Graphics and Flash 6 08-24-2006 04:16 AM
HTML Code: Centering Page kobedog84 Programming and Scripting 4 08-11-2006 01:35 PM
Create Email of Web Page Wayne Programming and Scripting 2 06-20-2006 03:58 PM
make HTML page searchable in any search engine lonskie1030 Programming and Scripting 1 04-19-2006 01:44 AM


All times are GMT -5. The time now is 05:44 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter