PHP Session Driving me cazy

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP Session Driving me cazy

Postby timlab55 » 04. September 2023 03:59

I'm trying to test out my program. Every time I run Xampp on the page (which has sessions), I get this error "Warning: session_start(): open(C:\WINDOWS\SESS_;ALKDJFPOQIEJFLAIJ;) FAILED: pERMISSION DENIED (13) IN d:\xampp\htdocs. I've researched and every time I failed. Any help, please?
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 04. September 2023 11:59

You probably have a strange setting for the session files, normally stored either in TMP folder or in session.save_path as defined in php.ini. See also https://www.php.net/manual/en/function. ... e-path.php
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 04. September 2023 15:39

Nobbie wrote:You probably have a strange setting for the session files, normally stored either in TMP folder or in session.save_path as defined in php.ini. See also https://www.php.net/manual/en/function.session-save-path.php

No settings have been define yet in the php.ini. Also XAMPP doesn't set this up for you to begin with. However, after reading what you sent to me all advice that I have read is for Linux. I'm on a windows machine and can't find any instructions how how to set this up for windows.
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 04. September 2023 19:32

Its the same for Linux and Windows. You either can setup in php.ini or in your PHP script (i gave you the appropriate link). As we dont know anything about your script, neither about your configuration, we cannot help any further.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 04. September 2023 22:46

Has it ever occurred to you that some people either don't understand or just learning PHP and were told this is the best way to understand what they are doing? I'm just learning and by learning I need expert help. Remember when you were just learning something new? I'm sure your teachers just didn't say what's the answer to 2+2? So once again, where do I need to start so that I can get my sessions to work right?
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby timlab55 » 05. September 2023 00:20

@Nobbie - Thank you for pushing me harder to get this figured out, as I have done it. It was so simple I couldn't believe it. I had to go into the PHP.ini file and add where I wanted the sessions to go and make sure I had that directory. Now on to the next problem. I have a page (called play.html). Inside play.html I have it loading in a CSS file. However, it doesn't load in the CSS file but doesn't give an error except can't find file. I"ve read lots of stuff about this, so what's the fix for this if you don't mind me asking?
Thanks
Dan
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 05. September 2023 12:01

Same problem as before - without any further information nobody can help on this. In the previous case you could have shown us your php.ini, whatelse?
Same here, why dont you simply show us your play.html plus giving us the full pathname of the requested CSS file? Isnt it most obvious that there might be any error (wrong filename, wrong path, wrong URL or whatever)? And if so, how are we supposed to find it out, without knowing anything?

What would you answer if someone asks for help, his car does not drive, why is that?
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 05. September 2023 18:37

i hope this helps.
My play.html is the following:
<?php
require_once ('../navbar/navbar.html');
?><!DOCTYPE html>

<html>

<head>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" hrefs="registration.css" type="text/css">
<title>Untitled</title>
<style>

</head>

My registration.css file is as follows:
label {
font-weight: 800;
color: #555;
}
body {
background:#9cd2de ;

}
.jumbotron {

background-color: #abed8e;
}

When I run it, none of the CSS shows up. This has happened to all my pages that is requesting CSS. So what I have done is the following:
Play.html
<html>

<head>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!--<link rel="stylesheet" hrefs="registration.css" type="text/css">-->
<title>Untitled</title>

<style>

label{

font-weight: 800;
color: #555;
}
body {
background:#9cd2de ;

}
.jumbotron {

background-color: #abed8e;
}
So I've included the CSS into the head of the page and it works. But I shouldn't have to do this. Any suggestions?
Dan
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 05. September 2023 19:33

Nobbie wrote:Same here, why dont you simply show us your play.html plus giving us the full pathname of the requested CSS file?


Did you follow? Where can i find the full pathname or your CSS file?

And as you can see in your own(!) script, the URL of the CSS file is a fully qualified URL like this:

Code: Select all
https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css


But you only provided this:

Code: Select all
"registration.css"


Last not least, what does "hrefs" mean?? The Tag has to be called "href=" and not "hrefs=". Soooo many errors in such a small space. Congrats - new worldrecord!

Try

Code: Select all
href="http://localhost/registration.css"


and you might be succesfull.... (but we still dont know the pathname of registration.css).
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 05. September 2023 23:46

And you're right, as I typed in the full qualified URL and it worked! Now comes the fun part. The full qualified URL is :"http://localhost/XXXXXX.XX/bylaws/registration.css", how can i make it shorter as when I put this on my pi I don't have to worry about changing a few 100 pages of coding?
THanks
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 06. September 2023 12:10

1) pi is running Linux, that comes with lots of powerfull tools to do global editings, replacements etc., like vi, sed, awk and more.There is no need for shortening the URL.

2) Anyway, if you like to shorten, at the very first only replace the typo hrefs=... by the correct href=..
This results in href="registration.css". If your play.html is on the same server and in the same folder as your registration.css (what we still dont know), this may already solve your problem as well, as you may ommit the http:// (the protocoll) and the path from the URL, if and only if the files are all in the same server and folder.

3) if you still have to apply the full URL of the CSS file for any reason, you could define an ALIAS in the server configuration (i.e. httpd.conf) like this

Alias /css/ c:/xampp/htdocs/XXXXXX.XX/bylaws/

and finally use this URL for the CSS file

Code: Select all
href="http://localhost/css/registration.css"


Instead of css you may use any token, even only c would do it:

Alias /c/ c:/xampp/htdocs/XXXXXX.XX/bylaws/

Code: Select all
href="http://localhost/c/registration.css"
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 06. September 2023 15:56

Hello and GM or GE where ever your from.
Okay, #2 is completed. I've taken out the "s" in the href. As for the directory tree if that is what your after, then here it is:
ROOT (OS)
Localhost
party/party.html. Party.html is calling to registration.css to do some basic formatting. It also has a menu and a person clicks on a menu item let's say "bylaws"
bylaws/bylaws.html Inside bylaws I have two required items to load. The first is a navbar (which has its own directory) which also has two CSS (CSS #1 and CSS #2). After the navbar does its thing, it goes back up to bylaws.html and again, loads in 2 CSS files.

So basically that is what it's doing. As usual, I did some reading yesterday (last night) and found something interesting. Let's say your load is in CSS #1. Then CSS #2 loads in. Now CSS #3 will override some of CSS #1 and CSS#2. They mentioned to try and put it in 1 file.
I hope this helps in the folder department of what is going on.
#3: Interesting about the Alias thing. So basically you telling the OS that if you come across something like this, go here. Now is this for ALL CSS files or just the one's you mentioned?

Thanks
Dan
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows

Re: PHP Session Driving me cazy

Postby Nobbie » 06. September 2023 19:55

timlab55 wrote:Now is this for ALL CSS files or just the one's you mentioned?


Its for ALL files, not only CSS. Its a server configuration and works on all incoming requests. Its NOT an "OS" option (OS = Operating System, either WIndows, Linux, MacOS or so), but a Webserver (= Apache) Option. The scope is restricted to the scope, WHERE you defined the ALIAS. That can be globally, can be inside of a VirtualHost or whatever. You *should* read the Apache documentation about ALIAS:

https://httpd.apache.org/docs/2.4/mod/m ... html#alias

Finally, I am out from now on. i offered all information and links you need. Apache configuration is a pretty sophisticated task and it takes everybody quite a long while to get an good Apache admin. I had to go thru this as well of course. It took me years. So dont give up too early, read and try. I wish you all the best.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: PHP Session Driving me cazy

Postby timlab55 » 06. September 2023 23:48

I was hoping this day didn't come early, but it has and I thank you for giving me all the info.
Good Luck.
Dan
timlab55
 
Posts: 11
Joined: 24. August 2023 22:38
XAMPP version: 7.3
Operating System: Windows


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 153 guests