C
C
Carry2015-10-01 15:02:34
PHP
Carry, 2015-10-01 15:02:34

Different cookies for each page how?

I have OpenServer on my local domain. Site work.
We have pages like:

  • work/name.php
  • work/cat.php
  • work/edit.php

Cookies for each page must be isolated (i.e. for each page its own data)
I tried to make a subdomain of the form:
  • name.work
  • cat.work
  • edit.work

it seems that the problem with cookies is solved in this way (I have not checked it yet), but another problem arose -
connected scripts, css, etc. do not see the main domain
Please advise how to solve my problem

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivanq, 2015-10-01
@carryx

Move the files to different folders, for example work/name.php to work/name/index.php and put setcookie("CookieName", "CookieValue");. Cookies will be written for this directory. And it's easier to enter work/name in the browser. Where did you see www.example.com/forum.php ?

W
Wheelie, 2015-10-01
@Wheelie

path=PATH - This attribute sets the subset of documents for which the cookie value is valid. For example, specifying "path=/win" will cause the cookie value to be valid for many documents in the /win/ directory, in the /wings/ directory, and files in the current directory with names like wind.html and windows.shtml. In order for cookies to be sent on each request to the server, you must specify the server's root directory, for example, "path=/".

citforum.ru/internet/html/cookie.shtml

D
Dmitry, 2015-10-01
@thewind

You read about cookies carefully. There you can specify the domain or mask, as well as the path for which the cookie will be visible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question