Jump to content

Help with Session... can't get it to work...


cowboysdude

Recommended Posts

I have gotten some help with this .... it looks great but it doesn't work.  I am using Joomla 1.54... if that helps...

What I did is put the first part in my index.php file...

The second part in a flashchat.php file...

 

Problem is when I try logging onto my site with this installed I get an error from my browser [both IE and Firefox]...and the site will not load.

When I take it out...it loads...to be more specific when I take the second part out of the flashchat.php file the site loads...

 

What I'm trying to do is make the user log on to the main site before and accessing the chat rather than just type a direct link into the browser to get to the chat [security because when inside the site the username is passed to the chat via php script]

 

I have tried .htaccess but I am running a web server on a WinXP machine and I've NO luck with that at all.... second choice and far safer [i think] is the session command....

 

How can I fix this?

 

 

Are all the files you want to protect PHP files? If they are you could use sessions. Add to index.php

Code:

<?php

 

session_start();

// If they don't visit index.php this variable won't be set.

$_SESSION['has_session'] = true;

 

 

Then in the PHP files you want protected

Code:

<?php

 

session_start();

// Check if the variable has been set.

if(!isset($_SESSION['has_session']))

{

  // It hasn't, they must go to index.php.

  header('Location: http://' . getenv('HTTP_HOST') . '/', true, 302);

  exit();

}

Link to comment
https://forums.phpfreaks.com/topic/116813-help-with-session-cant-get-it-to-work/
Share on other sites

I thought of that and had even excluded the first part but still won't load...unless the session start isn't the right variable?  The one located within the []?

 

Not sure...

 

I have just posted to the joomla forums asking if perhaps they can share how joomla creates a session already..it does from what I read so I'm hoping someone there can give me a clue about how or what.... that way I can change the second part of the what I posted here to work..

 

If Not well....

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.