Jump to content

Recommended Posts

The session.cookie_path determines the path that the session cookie will match. The default value of / should match any path -

session.cookie_path string

session.cookie_path specifies path to set in session_cookie. Defaults to /. See also session_get_cookie_params() and session_set_cookie_params().

 

Check what your session.cookie_path setting is using a phpinfo(); statement.

OK, then so u can have sessions, is the subdirectory the same url e.g. mysite.com/page.php (is the main one then subdirectory is) sub.mysite.com , or is it mysite.com/folder/index.php.

 

If its sub.mysite.com

i dont think sessions will pass through, also are you sure you are echoing the right session name , and if it has anything stored on it , try

error_reporting(E_ALL);

at the top.

can we see some code please ass long as every page got <?php session_start(); <<< at the beging ?> should work......... dont forget we mean every page including pages in other sub directorys..........

 

have you set the session's correctly...........

yes, session_id(); will be different everytime, because its a temporary id from session start (i beleive)

 

And yes ,session_start(); must be on every single page, everyone (other wise the person will go to one and there session will be destroyed)

 

 

this is part of my checklogin.php in the public_html folder

<?php
if($count=="1"){
session_register("myusername");
header("location: http://www.mysite.com/index.php");
}
else {
header("location: http://www.mysite.com/home.php?type=841927408208");
}
?>

 

this is part of my index.php in the public_html/administrator/ folder

<?php
session_start();
if(!session_is_registered(myusername)){
header("location:http://www.mysite.com/home.php?type=609421098494");
} ?>
... BLAH BLAH BLAH ...
<?php
$page = $_GET["page"];
$ext = $_GET["ext"];
if($page == "email"){
include_once("http://www.mysite.com/administrator/email/");
} else {
echo "<-- Click to navigate.";
echo session_id();
}
?>

 

this is part of my index.php in the public_html/administrator/email/ folder

<?php
session_start();
if(!session_is_registered(myusername)){
header("location:http://www.mysite.com/home.php?type=609421098494");
}
?>

<?php
if($count=="1"){
session_register("myusername");
header("location: http://www.mysite.com/index.php");
}
else {
header("location: http://www.mysite.com/home.php?type=841927408208");
}
?>

 

Where is session start?

 

also this is outdated i think ,

change

session_register("myusername");

to

$_SESSION['session_name'] = $value;

 

and change

if(!session_is_registered(myusername)){

to

if(!isset($_SESSION['session_name'])){

PROBLEM SOLVED!! THANKS ALL! especially blade :]

 

and instead of changing

if(!session_is_registered(myusername)){

to

if(!isset($_SESSION['session_name'])){

 

I changed

if(!session_is_registered(myusername)){

to

if(isset($_SESSION['session_name'])){

 

Notice there is no exclamation point.

Yes, i assumed you were checking to see if the session wasnt there, by checking to see if it exists (if not do)

 

But no problem, remeber session start, also maybe update your learning resource (for sessions anyways)

 

 

Edit: Click solved at the bottom :

Okay, i'm gonna try to explain it clearly.

 

1. You log in with the username and password in /public_html/index.php

2. The script checks if the username and password is correct, and if the username and password is correct, it creates a session called "myusername" and assigns it to $myusername, then the script redirects to the home page.

3. On top of the home page, there is a log in menu, the log in is actually a page called loginmenu.php in the public_html/ but it is actually include()'ed into the home page.

4. When somebody is logged in, it echos "hello $myusername" and it echos it good. Also to the right of Hello $myusername, it shows a link to "/administrator/"

5. This is where the problem is. When somebody goes to /administrator/, while the session is active, i see the login menu, instead of "Hello $myusername."

6. When i return to the root, it shows hello $myusername, and once again when i click /administrator/, i see the login menu, also btw, the login menu in /administrator/index.php is really and include of loginmenu.php in the root.

 

 

thanks you guys very very much!

Isset doesnt check if it has a value , it checks if the $var (in this case session) is present

 

try

<?php
session_start();
if(isset($_SESSION["myusername"])){
echo "session is set"
} else {
echo "session is set"
}
?>

 

There is no reason why this or the previous one wont work.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.