CSS does not load with $_SESSION

Asked

Viewed 100 times

-1

I load the CSS this way:

<link href="../css/style.css" rel="stylesheet">

But I’d like to give you a different reference, something like:

 <link href="<?php echo $_SESSION['caminho_completo']."css/style.css"?>" rel="stylesheet">

But when I do this the CSS doesn’t click on the page, what solution would you have for this?
Obs: works on the home.php that is inside the pages folder, but does not work for the files that are inside the 1998 folder.

inserir a descrição da imagem aqui

  • "first way also not charging, I believe it is some problem with the way" ... First you need to set the course, then resolve the session issue, otherwise it will be difficult until you test. It would be good [Edit] the question and why the HTML excerpt resulting from its second example.

  • if I can solve without using the session will be good

  • Have you tried putting the path from the root? (starting from the bar): /caminho/completo/css/style.css - And before testing on <link> try at least to access directly through the browser by typing the address in the address bar. For example, if your site is http://example.com and you can access your CSS by http://example.com/assets/css/style.css, the way from the root would be: href="/assets/css/style.css"

  • @That’s why I tried to use Septic, to go the whole way, but it didn’t work. I can access the CSS with this link "http://localhost/PMI-WEB-CONTAB-ALPHA/css/style.css"

  • 1

    Take a look at the source code (CTRL+u) and see what appears where the SESSION is. So you check what value is passing and if the path is correct.

  • @dvd the path looks like this: <link href="C: xampp htdocs PMI-WEB-CONTAB-ALPHA css/style.css" rel="stylesheet"> I don’t know if there would be any problem if the bars were inverted. The way is right

  • Yes. You want to link from the local server to a file on the computer?

  • I don’t know if I understood very well what you meant... but the intention is to use CSS in my system pages

  • In the files inside the "pages" folder the path should be ".. /css/style.css", in the "1998" folder should be ".. /.. /css/style.css"

  • the problem is that it is inside the header.php and the same is included in all the files: include("header.php"), both in the home that is inside the pages and in the files that are inside 1998

Show 5 more comments

1 answer

0

I believe that you have a config file in your project, if there is a suggestion to create one, in it you can define variables and constants to use in your project, example:

config.php

define('_LINK_BASE_', "http://exemplo.com.br");

index php.

<?php include_once('config.php'); ?>
<html>
    <head>
        <link href="<?php echo _LINK_BASE_; ?>/css/style.css" rel="stylesheet">
    </head>
</html>
  • I was doing the define on my index.php, but when I tried to use it on some different location I used Undefined, so I went to Session, but basically my header.php is config... instead of the address I put __ DIR __

  • __ DIR __ returns the directory of the current file equivalent to dirname(__ FILE __), tries to define the full path in the same arm, if always use the constant, when to put into production only via changing this constant.

  • will be an internal system, will be on a server here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.