Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find session already created

Status
Not open for further replies.

DrSlinky

Programmer
Jun 11, 2003
5
GB
Hello all

I am trying to create different named sessions every time someone calls my script

I was wondering if anyone knows of any functions that list already made session on my server or of any url that would give me the information I am looking for.

cheers

Dr Slinky
 
I don't understand. Why would you want to change the session id every time? You're adding additional complexity that you don't need.

You will, for example, have to write some kind of mechanism for tracking which user is using which session id, or the session system will fail.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Hello Sleipnir

Yes I already have a way of tracking which user is using my script. How ever I only want them to be able to open the same script 4 times at once. I also need to store what could be a large amount of information. Which I would need to refer to across many different scripts.

So I have created different session as per the user. But I can't find away to see if that user has already created a session. do you have any ideas how to find this at ??

cheers Dr Slinky









 
I don't have an answer to your question... but this sounds like a problem better handled by a database. Failing a database at your disposal, I'd setup a flatfile and use it as a counter.

If you really really want to do it through sessions, you can figure out your session directory on the webserver, set one of your session variables to the user name, then parse all the files in the session directory. This seems like a rather innefficient method, and rather non portable. Additionally you'll need to be more creative than I stated in case another script may also create sessions with the same information. And if you're talking a busy server that creates sessions for other things, you could have thousands of files to go through.

-Rob
 
Not really sure what you need but if you just want to check whether the session is created

you can just check whether the particular session variable exist.. for example asign a loginname to a session
Code:
if ($_SESSION["login"] == ""){ // session variable empty or not yet have a value 

$_SESSION["login"] = "abc123"; // whatever the session id is 
$_SESSION["accessed"] = 1; // how many times the person has accessed the page

}
else { // if user has accessed it once at least

   if($_SESSION["accessed"] == 4){
           // do something or disallow
    } 
   else {
       $_SESSION["accessed"] = $_SESSION["accessed"] +1; // increment number of accessed
   }
}

Regards,

Namida
 
Thank you all for your help..

I have decide to go down the route of adding a var to the session. and every time the session is opened the vars is
incremented.

cheers
Dr Slinky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top